Add execute multiple commands on ssh

This commit is contained in:
Jean-Claude 2023-06-02 22:37:45 +02:00
parent 865c93a955
commit df3cb21b60
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
1 changed files with 19 additions and 0 deletions

19
bash.md
View File

@ -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`