C
Charles_hans
I am new to paramiko. I wrote a script to copy files between Solaris and XP
machines as below:
import paramiko
def exec_command(trans, command):
chan = trans.open_session()
chan.exec_command(command)
stdin = chan.makefile('wb')
stdout = chan.makefile('rb')
stderr = chan.makefile_stderr('rb')
return stdin, stdout, stderr
def main():
client = paramiko.SSHClient()
client.connect(hostname, username=username, password=password)
trans = client.get_transport()
dummy_chan = trans.open_session()
exec_command(trans, 'cd temp')
stdin, stdout, stderr = exec_command(pwd)
mkdir, cp, rm will work. Only this 'cd' never works. I got stuck here.
Please help. Thanks!
Charles
2/2
machines as below:
import paramiko
def exec_command(trans, command):
chan = trans.open_session()
chan.exec_command(command)
stdin = chan.makefile('wb')
stdout = chan.makefile('rb')
stderr = chan.makefile_stderr('rb')
return stdin, stdout, stderr
def main():
client = paramiko.SSHClient()
client.connect(hostname, username=username, password=password)
trans = client.get_transport()
dummy_chan = trans.open_session()
exec_command(trans, 'cd temp')
stdin, stdout, stderr = exec_command(pwd)
to type the full path in 'cd', did not help. Other UNIX commands such as ls,From the last line I found from stdout that the pwd is not changed. I tried
mkdir, cp, rm will work. Only this 'cd' never works. I got stuck here.
Please help. Thanks!
Charles
2/2