I've tried the following three ways to change a directory and it never changes. has anyone else had this problem?
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
host = 'server1.mydomain.com' # altered
with pysftp.Connection(host=host, **get_credentials(), cnopts=cnopts) as connection:
connection.execute('cd project')
print(connection.execute('pwd')) #---> [b'/home/jm\n']
connection.execute('cd /home/jm/project')
print(connection.execute('pwd')) #---> [b'/home/jm\n']
connection.cd('project')
print(connection.execute('pwd')) #---> [b'/home/jm\n']
with connection.cd('project'):
print(connection.execute('pwd')) #---> [b'/home/jm\n']
'/home/jm/project/'
does exist by the way. I've also trid many other combinations that I didn't list here.
It doesn't make any sense to me, can you help?