cat << 'EOF' |sudo tee /tmp/yourprotectedfilehereThe variable $FOO will *not* be interpreted.EOF
cat << "EOF" |sudo tee /tmp/yourprotectedfilehereThe variable $FOO *will* be interpreted.EOF
while read pass port user ip files directs; dosshpass -p$pass scp -o 'StrictHostKeyChecking no' -P $port $files $user@$ip:$directsdone <<____HEREPASS PORT USER IP FILES DIRECTS. . . . . .. . . . . .. . . . . .PASS PORT USER IP FILES DIRECTS____HERE
第二(执行命令):
while read pass port user ip; dosshpass -p$pass ssh -p $port $user@$ip <<ENDSSH1COMMAND 1...COMMAND nENDSSH1done <<____HEREPASS PORT USER IP. . . .. . . .. . . .PASS PORT USER IP____HERE
第三(执行命令):
Script=$'#Your commands'
while read pass port user ip; dosshpass -p$pass ssh -o 'StrictHostKeyChecking no' -p $port $user@$ip "$Script"
done <<___HEREPASS PORT USER IP. . . .. . . .. . . .PASS PORT USER IP___HERE
Forth(使用变量):
while read pass port user ip fileoutput; dosshpass -p$pass ssh -o 'StrictHostKeyChecking no' -p $port $user@$ip fileinput=$fileinput 'bash -s'<<ENDSSH1#Your command > $fileinput#Your command > $fileinputENDSSH1done <<____HEREPASS PORT USER IP FILE-OUTPUT. . . . .. . . . .. . . . .PASS PORT USER IP FILE-OUTPUT____HERE
cat << EOF > /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, with the variable contents substituted.EOF
To append an existing file (or write to a new file) that you own, substituting variable references inside the heredoc:
cat << FOE >> /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, with the variable contents substituted.FOE
To overwrite an existing file (or write to a new file) that you own, with the literal contents of the heredoc:
cat << 'END_OF_FILE' > /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, without the variable contents substituted.END_OF_FILE
To append an existing file (or write to a new file) that you own, with the literal contents of the heredoc:
cat << 'eof' >> /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, without the variable contents substituted.eof
To overwrite an existing file (or write to a new file) owned by root, substituting variable references inside the heredoc:
cat << until_it_ends | sudo tee /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, with the variable contents substituted.until_it_ends
To append an existing file (or write to a new file) owned by user=foo, with the literal contents of the heredoc:
cat << 'Screw_you_Foo' | sudo -u foo tee -a /path/to/your/fileThis line will write to the file.${THIS} will also write to the file, without the variable contents substituted.Screw_you_Foo