I have a bash script which ssh's to a server, and depending on the status of a variable performs a task:
#!/bin/bash
foo=$1
ssh [email protected] '
echo In host
if [ "$foo" == "yes" ]; then
echo "Foo!"
fi
'
When I run sh script.sh yes, although the ssh command works, the conditional evaluates to false. I can see this if I echo $foo - it prints an empty line. How can I access the value of foo within the ssh command?