I am writing a program to ssh into another computer on our network. However with the commands ssh, scp etc... terminal requests the password and os.system() seems to open a new terminal window each time it is called. This makes it difficult to enter the password.

I have been looking at os.system(), popen() and appscript's app(u'/Applications/Utilities/Terminal').do_script().

Any help would be greatly appreciated.

have you tried with the FTP facilities ?

18.8 ftplib -- FTP protocol client

Remotely connecting to other systems by invoking external bash commands is cumbersome, isn't it? You'd be better served by learning how to use the paramiko package, which lets you do the same thing but from within Python:

http://www.lag.net/paramiko

Check out the instructions that come with the package for short demos on how to connect to remote systems. I use it at work, and it wasn't too much hassle to set up and use.

There are ways of doing this with os.popen(), if you're dead set on doing things that way - you can use "here documents" to enter the password and commands, I believe - but I haven't actually tried that on my own, so don't hold me to it.

Hope that helps.

paramiko seems to be just the ticket. Thanks!

I've successfully used telnetlib (included in Python, I believe) in similar cases. Telnet is a more primitive remote-terminal protocol which suffers from a number of security issues, one reason why SSH was developed. If you can use paramiko then by all means do so. But if you run into problems with it, consider telnetlib. In my case security is not an issue due to physical isolation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.