<div class="gmail_quote">On Thu, Sep 30, 2010 at 7:27 AM, R. Alan Monroe <span dir="ltr">&lt;<a href="mailto:amonroe@columbus.rr.com">amonroe@columbus.rr.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
&gt;&gt; I&#39;m needing to transfer the following shell construct to Python,<br>
&gt;&gt; plus save<br>
&gt;&gt; the output of execution:<br>
<br>
</div><div class="im">&gt;&gt; FTP_SITE=&#39;<a href="http://ftp.somesite.com" target="_blank">ftp.somesite.com</a>&#39;<br>
&gt;&gt; ftp -a  $FTP_SITE &lt;&lt;EOF<br>
&gt;&gt; binary<br>
&gt;&gt; prompt off<br>
&gt;&gt; cd /some_dir<br>
&gt;&gt; dir<br>
&gt;&gt; bye<br>
&gt;&gt; EOF<br>
<br>

</div>NB: If you use the ftp module (which works great), be sure to open all<br>
files in Binary mode. Voice of experience here.</blockquote><div><br>Thanks all, for the responses thus far.  I was not aware of the ftplib module.  This looks like it will take care of most of my needs.<br><br>However, output from these FTP commands are sent to stdout.  Is there a way to redirect/capture stdout, as I need to parse the directory listings?<br>
<br>Thanks, again. <br></div></div><br>