I'm new to shell scripting and having a little trouble.
I'm trying to execute a remote script from local machine. The script on local machine is passed four arguments, and it executes the following line:
ssh $STACK 'bash -l -c "./deploy_intermediate.sh $2 $3 $4"'
However, I cannot get $2, $3, and $4 to put out the passed arguments. Is there any way to be able to access them within single quotes? What is the best way of executing the above line.
I would really appreciate any help.
thanks.
The trick is:
ssh -i ~/.ssh/"$GIT_PRIVKEY" user@"$IP" "bash -s" < localpath/script.sh "$arg1" "$arg2"
To pass the parameters you'd have to write:
ssh $STACK 'bash -l -c "./deploy_intermediate.sh '$2 $3 $4'"'
Thus you make way for the $i
values to be expanded. Yet, I think you'd probably be able to get the same result by simply running:
ssh $STACK "./deploy_intermediate.sh $2 $3 $4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With