Tuesday, February 12, 2019

command line - how to use expect with bash

I Have created a shell script as given below.This script will login to a remote server as a normal user then switch to root user for creating a directory.The script is as given below.





ssh -t qbadmin@10.3.2.0 '
su root -c "
echo \"Give Directory name :\";
read dir;
mkdir \$dir;
";
'




Here the script will ask Password for normal user first.Then again it will ask for root Password.How could I automate this using expect command.I want to supply the password automatically for the root user only.I think it can be done with expect.



Please do help me.

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...