OS specific command in Python

Avell Diroll avelldiroll at yahoo.fr
Tue Jun 20 02:52:40 EDT 2006


diffuser78 at gmail.com wrote:
> I want to write a python program and call OS specific commands in it.
> So basically, instead of typing in on the command line argument I want
> to have it in a python program and let it do the action.

There are several ways to do so :
* os.system() if you just want to launch a command (kind of fire-and-forget)
* the subprocess module if you want to access stdin, stdout and stderr 
of the launched command

> 
> for example. in my program I would want to call the ssh feature like
> one does on the command line
> 
> ssh Admin at 192.168.2.10          .....etc

To interact with an ssh process , there is a great module called pexpect 
  (featuring some examples of how to handle ssh process in python)
http://pexpect.sourceforge.net/


OT : paramiko is a module to handle the SSH2 protocol in python
http://www.lag.net/paramiko/




More information about the Python-list mailing list