I am trying to ssh into a buildserver on the network and run some commands and logout of the server,i have looked at other posts and written the following code but its not working?can anyone suggest what is wrong or is there a better way to accomplish this?thanks in advance
import os
import sys
import pexpect
#os.system(ssh username@buildservername)
child = pexpect.spawn('ssh username@buildservername', logfile=sys.stdout)
#child.expect('Are you sure you want to continue connecting (yes/no)?')
#child.sendline('yes')
#child.expect('password:')
child.sendline('password')
cmd = 'hostname'
os.system(cmd)
os.chdir('//local/mnt/workspace')
os.mkdir('newdir')
os.getcwd()