0

i have a expect script like

#!/usr/bin/expect
.....
spawn passwd
expect "password:"
send "password"
....
....
....
~/test.sh

Wile executing this, I'm unable to run bash script test.sh.

How to execute Linux commands/bash scripts inside Expect script?

1

To begin with you should use spawn to run your script, and I'm not certain the tilde construct will be interpreted by expect.

spawn /bin/bash /home/username/test.sh

You should have error messages when this happens, you should add the to your question if you do not understand them.

6

You can use the tcl exec command, which normally collects the output, so redirect it:

#!/usr/bin/expect
...
exec ~/test.sh  >@stdout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.