Why chdir command doesn't work with client.get_transport() ?

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)
From the last line I found from stdout that the pwd is not changed. I tried
to type the full path in 'cd', did not help. Other UNIX commands such as ls,
mkdir, cp, rm will work. Only this 'cd' never works. I got stuck here.

Please help. Thanks!

Charles
2/2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top