What path is the file? <br><br><div><span class="gmail_quote">On 6/14/05, <b class="gmail_sendername">Gary Taylor</b> &lt;<a href="mailto:squeaky@sdf.lonestar.org">squeaky@sdf.lonestar.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm trying to pass the name of a file as the first argument<br>to the ftp.storbinary function(?) below.&nbsp;&nbsp;The only thing I<br>can get to work is the real file name hard coded as the<br>argument.&nbsp;&nbsp;I've tried parenthesis, single quotes, double
<br>quotes, and many combinations of the previous. I've tried<br>passing sys.argv[1] directly as well, although with fewer<br>experiments.<br><br>I invoke this as below and the output is what I would<br>expect, but the file name on the ftp server is never
<br>correct.<br><br><br>What is the correct way to do this?<br><br><br>$ ./garyftp.py <a href="http://align.ps">align.ps</a><br><a href="http://align.ps">align.ps</a><br><br><br><br>---<br>Python 2.3.4 on Linux.<br><br><br>
---<br>#!/usr/bin/python<br>import sys<br>from ftplib import FTP<br><br>file_to_transfer = sys.argv[1]<br><br>ftp = FTP()<br>ftp.connect(&quot;myserver&quot;)<br>ftp.login(&quot;myusername&quot;, &quot;mypasswd&quot;)<br>
<br><br>ftp.storbinary(stor file_to_transfer, open(file_to_transfer,&quot;r&quot;))<br><br>print file_to_transfer<br>ftp.quit()<br>--<br><br>Thanks,<br>Gary<br><br><a href="mailto:squeaky@sdf.lonestar.org">squeaky@sdf.lonestar.org
</a><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor
</a><br></blockquote></div><br><br><br>-- <br>'There is only one basic human right, and that is to do as you damn well please.<br>And with it comes the only basic human duty, to take the consequences.'