I am trying to automate pbrun using the following code
ssh [email protected]
pbrun -u user1 bash
pass active directory password
run the command
exit
I created the following script but it's not able to pass the password for pbrun:
import time
import pexpect
child = pexpect.spawn('ssh [email protected]')
child.expect("[email protected]'s password:")
child.sendline('Password')
child.expect ('.')
child = pexpect.spawn ('pbrun -u user1 bash')
child.expect ('.*')
time.sleep(10)
child.sendline ('Password') - Active directory password
child.expect ('.*')
child.sendline ('ls')
data = child.readline('ls')
print data
The above code successfully does ssh and runs pbrun but is unable to send the password asked by pbrun. Any help is appreciated.
I was able to achieve this by below script, tried python but was not successful, sharing this script which may be helpful to others.
Run the script as below:
here passfile.txt has the password in text and myscript.sh has the pbrun command