Reputation: 2052
This is probably very basic but unfortunately I have no idea how to google it.
Why doesn't the snippet below work as expected? I mean, how can I make cat
point to the remote file?
#!/bin/bash
ssh user@remoteaddress << EOF
mkdir sandpit
cd sandpit
echo "foo" > foo.txt
echo `cat foo.txt` > foo2.txt
EOF
Upvotes: 0
Views: 469
Reputation: 785296
Use it as:
ssh -t -t user@remoteaddress<<'EOF'
mkdir sandpit
cd sandpit
echo "foo" > foo.txt
cat foo.txt > foo2.txt
xargs kill < pid.txt
exit
EOF
Without quotes around starting EOF
all words are subject to shell expansion and reverse quotes are expanded in your current shell not on ssh.
Upvotes: 3