Reputation: 11
I have to connect to a different cli and execute few commands and exit. sudo $SIGNMCLI
connects to a cli. The below script doesn't work. I want to execute the exit in SIGNMCLI
.
#!/bin/bash -xv
SIGNMCLI=/opt/sign/EABss7024/bin/signmcli
if [ -f "$FileCheck" ];
then
sudo $SIGNMCLI
exit;
fi
If I do the following, it works:
#!/bin/bash -xv
SIGNMCLI=/opt/sign/EABss7024/bin/signmcli
if [ -f "$FileCheck" ];
then
echo 'exit' |sudo $SIGNMCLI
fi
But, I want to execute multiple commands in SIGNMCLI
. Is there anyway to redirect the control to SIGNMCLI
and after executing all the commands, the control comes back?
Upvotes: 1
Views: 821
Reputation: 4920
You can execute multiple commands using semicolon operator in your script.
cmd1 ; cmd2 ; cmd3 ...
In you case, I suggest you to use ; or &.
echo 'exit'; sudo $SIGNMCLI
This is the basic usage of commands.
* A; B Run A and then B, regardless of success of A
* A && B Run B if A succeeded
* A || B Run B if A failed
* A & Run A in background.
Upvotes: 1