with c as c: res = c.run('pwd') with c.cd('/home/yy/Desktop/'): res2 = c.run('pwd') path = os.path.join((res2.stdout).strip(),'sdata/bin') res3 = connect = c.run('ls') with c.cd(path):