Reputation: 2359
I am writing a script in which i have to execute a set of statments after logging in via SSH. So i am using this command
ssh -t [email protected] $COMMAND "&& exec bash -l"
Now this works if i give COMMAND
as any single line statement such as ls
or mkdir
, but its not working if i put the following in COMMAND
COMMAND= "if [ $B==$A ]
then
echo 'ERROR'
fi "
I tried putting \
at the end of each line,changed the indentation,put it into a single line but its throwing error
fi : command not found
syntax error near unexpected token `&&'
Upvotes: 2
Views: 96
Reputation: 1752
The first problem is the ssh statement itself. ssh command should be run like:
ssh -t [email protected] $COMMAND && exec bash -l
Second one is that COMMAND
variable should be assigned as one line like:
COMMAND="if [ $B==$A ]; then echo 'ERROR'; fi;"
I hope this helps.
Upvotes: 1