You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
733 B
32 lines
733 B
|
13 years ago
|
#!/usr/bin/env python
|
||
|
|
|
||
|
|
import os, sys
|
||
|
|
|
||
|
|
# first let's copy the script to be run (can be python, shell, perl, whatever =)
|
||
|
|
#stdin, stdout, stderr = os.popen3("scp -p myScript.py remotehost:")
|
||
|
|
|
||
|
|
# close the previous file descriptors:
|
||
|
|
#stdin.close()
|
||
|
|
#stdout.close()
|
||
|
|
#stderr.close()
|
||
|
|
|
||
|
|
# and now ssh into the remotehost and launch the script we just uploaded to it...
|
||
|
|
stdin, stdout, stderr = os.popen3("ssh study1 -ladelux")
|
||
|
|
|
||
|
|
# pass password
|
||
|
|
stdin.write("""adelux""")
|
||
|
|
|
||
|
|
print stdout.read()
|
||
|
|
|
||
|
|
# chmod and execute the script...
|
||
|
|
#stdin.write("""chmod 700 myScript.py\n""")
|
||
|
|
#stdin.write("""./myScript.py\n""")
|
||
|
|
|
||
|
|
# then close the ssh connection
|
||
|
|
stdin.write("""exit\n""")
|
||
|
|
|
||
|
|
# and close the file descriptors:
|
||
|
|
stdin.close()
|
||
|
|
stdout.close()
|
||
|
|
stderr.close()
|