For example, if I want to retrieve some data from
\\remcomputer\datafiles on the network and copy it to my local
computer, how do I do it in python on the Unix side?
I don't want to use mount since I don't have permission.
Thanks
Thierry
import pexpect
import sys
child = pexpect.spawn ('ftp ftp.site.com')
child.expect ('Name .*: ')
child.sendline ('username')
child.expect ('Password:')
child.sendline ('password')
child.expect ('ftp> ')
child.sendline ('cd testdir')
child.expect ('ftp> ')
child.sendline ('bin')
child.expect ('ftp> ')
child.sendline ('hash')
child.expect ('ftp> ')
child.sendline ('get testfile')
child.expect ('ftp> ')
print child.before
child.sendline ('bye')
Raghu.
~
If the remote computer is running an ftp server, yes. If not, no.
> For example, if I want to retrieve some data from
> \\remcomputer\datafiles on the network and copy it to my local
> computer, how do I do it in python on the Unix side?
>
> I don't want to use mount since I don't have permission.
http://miketeo.net/projects/pysmb/
--
Robert Kern
rk...@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
... and, for those for whome pexpect is somehow infeasible,
there are a variety of ways to work around its absence <URL:
http://phaseit.net/claird/comp.unix.programmer/ftp_automation.html >.
I use ftplib in the standard libraries.
from ftplib import FTP
def grab_geneontology():
"""Function to download gene ontology file."""
ftp = FTP('ftp.geneontology.org')
ftp.login()
ftp.cwd('/pub/go/ontology')
ftp.retrbinary('retr gene_ontology.obo',
open('gdata/gene_ontology', 'wb').write)
ftp.quit()
if __name__ == '__main__': grab_geneontology()
maurice
> Is it possible to run an ftp command to connect to some remote computer
> on the network.
Yes, but why would you want to do taht?
> For example, if I want to retrieve some data from
> \\remcomputer\datafiles on the network and copy it to my local
> computer, how do I do it in python on the Unix side?
Start with "import ftplib". Use ftplib to read the file, and write it
out wherever you want it - or don't, if the goal was to get the
contents of the file into your Python program. The API is sorta ugly,
but it works, and comes with Python.
<mike
--
Mike Meyer <m...@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.