Shell commands from within a script

Emile van Sebille emile at fenx.com
Wed Nov 14 10:53:22 EST 2001


"Neil Fryer" <neil at cxchange.co.za> wrote in message
news:mailman.1005745399.3684.python-list at python.org...
> Hi All
>
> I'm really new to python so if you could please let me know how to execute
a
> command like say, ftp, from within a script it really would be
appreciated.
> As I'm only about half way through my first Python tutorial.
>

>>> import ftplib
>>> print ftplib.__doc__
An FTP client class and some helper functions.

Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds

Example:

>>> from ftplib import FTP
>>> ftp = FTP('ftp.python.org') # connect to host, default port
>>> ftp.login() # default, i.e.: user anonymous, passwd user at hostname
'230 Guest login ok, access restrictions apply.'
>>> ftp.retrlines('LIST') # list directory contents
total 9
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc
d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming
drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib
drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub
drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr
-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg
'226 Transfer complete.'
>>> ftp.quit()
'221 Goodbye.'
>>>


--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list