Add execute multiple commands on ssh
This commit is contained in:
parent
865c93a955
commit
df3cb21b60
19
bash.md
19
bash.md
|
@ -31,3 +31,22 @@
|
|||
|
||||
- Function output to variable:
|
||||
`result=$(myfunc)`
|
||||
|
||||
## SSH
|
||||
- Execute set of commands on remote
|
||||
```
|
||||
ssh MYREMOTE /bin/bash << EOF
|
||||
cmd1;
|
||||
cmd2;
|
||||
cmd3
|
||||
EOF
|
||||
if [ $? -ne 0 ]; then
|
||||
# One of the commands failes
|
||||
fi
|
||||
```
|
||||
|
||||
- Return code is return code of executed command
|
||||
- Except if ssh fails
|
||||
|
||||
- Combine command outputs: `{ command1 & command2; }`
|
||||
- Can also be redirected: `{ command1 & command2; } > new_file`
|
||||
|
|
Loading…
Reference in New Issue