The first step:
SSH Password-free login "with public key, private key"
Step Two:
#!/bin/bash while read server; Do "[email protected]" 2 >& 1 "s/^/$ Server:/" &donewait
./bunsan2.sh Free < Servers.txt
Note: While read server considers the input as a variable server
-N SSH option, no read for standard input.
"[Email protected]" to cycle.
2 >&1 without this command, the SSH command writes to the content of the standard error output and is not passed to the SED command. It does this by specifying the beginning of the standard error output to be the same as the standard input.
& Background processing. If this is not the case, a command executes too long to execute the following command.
Step Three:
Contents of the Servers.txt file
[Email protected] 58.241. 41.141 [email protected] 58.241. 41.142 [email protected] 58.241. 41.143
./bunsan2.sh Free < Servers.txt
You can see the results of the three rows.
./bunsan2.sh Free < Servers.txt >dgx.txt or so, continue with redirection.
Shell command-line statements