I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues:
set REMOTE "/root/scripts/remote"
...
log_user 1
send_user "Executing remote script as $user...\n"
send_user "Command to execute is: $REMOTE $user sudoers $hostfile\n"
exec /root/scripts/remote $user sudoers $hostfile
expect {
"Password for *" {
send -- "$password\r"
}
}
The remote expect script contains:
exp_internal -f /tmp/expect.log 0
so I can log what is going on.
So I run the sudoers.push script with the usage:
./sudoers.push <username> <host_list>
# ./sudoers.push bretski test-hosts
Password for bretski?
Moving sudoers to host XXXXX-0014...
Executing remote script as bretski...
Command to execute is: /root/scripts/remote bretski sudoers test-hosts
<hangs right here>
My log file has the output that I should see on my screen from executing the remote script
# cat /tmp/expect.log
Password for bretski?
expect: does "" (spawn_id 0) match regular expression "(.*)\n"? no
My question is why, when I call the "remote" expect script from within my sudoers.push expect script, does the output from remote not output to the terminal like it would if I ran it normally from the command line?