Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

#!/usr/bin/expect
...
exec ~/test.sh  >@stdout
share|improve this answer
    
I didn't think of exec. I suppose it depends on what Dinesh wants to do. Redirects here: stackoverflow.com/questions/554304/… – Law29 2 days ago

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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