first connect to the remote server, execute a script on the remote server, and the execution result will be saved in result.txt. There are three possible results: process failed success, wait 5 minutes if it is process, exit the entire script if it is failed, and get a compiled package from the remote server if it is success. The reason for writing the result to a file is that the script takes a long time to execute on the remote server, needs to be executed asynchronously, and serial execution takes a lot of time.
currently I search and know how to read the contents of a file from a remote server, the code is as follows:
out=$(ssh root@$source <<"EOF"
while IFS= read -r line; do
printf "Data : %s\n" "$line"
done < "data.txt"
EOF
)
the above code will cycle through a file, one line at a time, but I want to read one line at a time, judge the content, and then report a grammar error if I don"t want to read it every 5 minutes.
first of all, when I run it, I will always prompt Pseudo-terminal will not be allocated because stdin is not a terminal, that I don"t know if this has any effect. In fact, through bash-x, I can see that the content of the first line in the data.txt under the remote server ~ that is / root can be obtained accurately, but out has been obtained once. How can I implement the above judgment logic I mentioned? if the content is not success and failed, wait for 5 minutes. Then if it is success, it is like a remote server to get the package, and if it is failed, it will end the execution of the native script.