| | |
Multi-line terminal commands
![]() |
•
•
Join Date: May 2007
Posts: 2
Reputation:
Solved Threads: 0
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.
I have been looking at os.system(), popen() and appscript's app(u'/Applications/Utilities/Terminal').do_script().
Any help would be greatly appreciated.
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.
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.
Vi veri veniversum vivus vici
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.
![]() |
Similar Threads
- Mail keeps going offline (OS X)
- Multi-line Tool/Tip Text (Visual Basic 4 / 5 / 6)
- Compiling and running an entire poject from command line/terminal on Linux (IT Professionals' Lounge)
Other Threads in the Python Forum
- Previous Thread: wxCanvas-Get current coordinates
- Next Thread: can't figure out loop
| Thread Tools | Search this Thread |
abrupt alarm ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui halp heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib





