The following three lines having three commands(spawn,expect,send), but what it does actually. Please explain any one
spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no usr@$myhost.example.com'<br>
expect "password"<br>
send "$PWD\n" <br>
EOD
The Linux expect command takes script writing to an entirely new level. Instead of automating processes, it automates running and responding to other scripts. In other words, you can write a script that asks how you are and then create an expect script that both runs it and tells it that you're ok.
Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high- level control structures to direct the dialogue.
The SPAWN procedure spawns a child process to execute a command or series of commands. The result of calling SPAWN depends on the platform on which it is being used: Under UNIX, the shell used (if any) is obtained from the SHELL environment variable.
Bash scripts provide many programs and features to carry out system automation tasks. The expect command offers a way to control interactive applications which require user input to continue.
It is part of an expect script:
spawn
opens a new process
expect
waits for the previous spawned process to output the "expected" string (password in this case)
send
writes to the spawned process stdin
EOD
has no meaning in expect, perhaps it is part of another script?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With