Use Case:
1> ssh into a machine -->using the expect script automation
2> Once ssh'ed into the machine run a script from my local machine onto the remote machine
Currently I'm doing the following approach:
ssh [email protected] < ./s4.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
[email protected]'s password: <Provide password>
<Script executes without any errors>
In the above scenario, I have to provide my password manually which is not the intended use case for automation.
So will be using the expect option which should help automate the login procedure.
Sample Code:
#!/usr/bin/expect -f
spawn ssh [email protected]
expect "password"
send "password\r"
This code helps automate the login, but in the expect code... how will I give the command to trigger another script from inside my current script?
expect
? Reason I am asking: Executing a script through SSH does not requireexpect
(there are easier ways to do this). If you still wish to useexpect
, the tags should be adjusted.