Home > OS > For help on writing a shell script called expect on other nodes, how to obtain the return value judg
For help on writing a shell script called expect on other nodes, how to obtain the return value judg
Time:09-30
Purpose is by calling the shell script with expect from a node automatically log in to the node b, then verify whether a directory on the node b ok files to arrive, if not verified sleep again after a period of time until the scan 5 times no file, or scan to file the exit after 0, want to pass inspection schedule every day to run a shell script, Now write a really don't know how to obtain the find the command result then in a shell script below if then, usually with the shell is not very skilled, hope everyone to help see, #!/bin/bash File_pwd='/bigdata/data/20190902' Usr/bin/expect & lt; -Set the timeout 5 Spawn SSH $1 @ $2 Expect { "(yes/no)?" {the send "yes \ n"} "Password:" {send "hadoop \ n"} Eof} Send "the find ${file_pwd} | awk -f. ' ' '{print $2}" Expect eof Interact EOF
CodePudding user response:
Don't know how to convey variables to expect the shell, so I will only in the expect output a value or a string, and then back to the shell to get the value, to determine, this way,
Like this, can have some output function this function, through the processing, the echo of the string, filtering, assign a value to a variable status, and then to judgment, then add some actions in the rear