curl-and-python

Pass string (and not a file) to FTP...

From: Christian Malmquist <cmalmqui_at_imap.cc>
Date: Wed, 10 Feb 2010 23:15:13 +0100 (CET)

Hello,
Just started scripting a small app that will send some info from a maemo
phone to my ftp server at regular intervals. Using pycurl for the job, but
have not yet been able to pass a string across instead of a file.

The below script is how I would like the code to be, and I would be
grateful if anyone on this list could give me some hints in order to get
this project flying.

import pycurl
string_to_upload = "Dette er en test..."
c = pycurl.Curl()
c.setopt(c.URL, 'ftp://ftp.server.org/curltest.txt')
c.setopt(c.FTPAPPEND, 1)
c.setopt(c.USERPWD, 'curluser:curlpwd')
c.setopt(c.FTP_USE_EPSV, 1)
c.setopt(c.WRITEDATA, string_to_upload)
c.perform()
c.close()

Thanks in advance for any help!

PS: I guess a better option would be to post the info across to a python
script running on my webserver. But I opted for the easier FTP approach as
I am not sure how to write the serverside script. I found plenty of docs
detailing the libcurl on client side, but not much on how to write the
server side.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2010-02-10