Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does spawn ,expect and send command in linux/unix

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
like image 267
narasimharao vayala Avatar asked Jun 15 '16 10:06

narasimharao vayala


People also ask

What is expect command in Unix?

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.

What is expect in Linux?

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.

What is the command spawn?

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.

What is bash expect?

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.


1 Answers

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?

like image 67
fedterzi Avatar answered Sep 22 '22 12:09

fedterzi