Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40255
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-03-01 06:18 -0800 |
| Message-ID | <4fcc93b7-3be9-416f-a2d4-bdc6cba2133e@googlegroups.com> (permalink) |
| Subject | os.system() not responding on django... any reason? |
| From | Jaiky <jaiprakashsingh213@gmail.com> |
import sys,os
sys.stderr = open('/dev/null')
import paramiko
sys.stderr = sys.__stderr__
os.system("echo \'s3\' >> myfile.txt ") #debug first in ssh2
def ssh2_connect(host, user, pswd, port=22):
try:
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, user, pswd)
return ssh
except Exception, e:
return str(e) + "Error. Failed to connect. Wrong IP/Username/Password"
def ssh2_exec(ssh, cmd, sudo=False):
result = []
try:
channel = ssh.get_transport().open_session()
if sudo:
channel.get_pty()
except:
return result
stdin = channel.makefile('wb')
stdout = channel.makefile('rb')
channel.exec_command(cmd)
exit_status = channel.recv_exit_status()
if exit_status == 0:
for line in stdout:
result.append(line)
channel.close()
return result
def ssh2_close(ssh):
ssh.close()
return
def ssh2_copyToFile(ssh, local_file, remote_file):
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
sftp.put(local_file, remote_file)
return
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 06:18 -0800
Re: os.system() not responding on django... any reason? Roy Smith <roy@panix.com> - 2013-03-01 09:24 -0500
Re: os.system() not responding on django... any reason? "marduk@python.net" <marduk@python.net> - 2013-03-01 09:59 -0500
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:23 -0800
Re: os.system() not responding on django... any reason? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-01 19:20 +0000
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:24 -0800
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:23 -0800
Re: os.system() not responding on django... any reason? Jaiky <jaiprakashsingh213@gmail.com> - 2013-03-01 08:24 -0800
csiph-web