I get the following error that is flagging on the last line of my code (which is empty):
syntax error: unexpected end of file
I can't figure out why it's saying this. I'm simply trying to use a here-doc
for an ssh connection:
#!/bin/sh
connectToServer() {
ssh -t root@$1 <<- ENDSSH
echo "Connected to server!"
ENDSSH
}
connectToServer $1
What's wrong with this code?
EDIT
Thanks to those of you who helped me to troubleshoot this. There were a couple of things wrong with my script; I was using spaces on the line:
echo "Connected to server"
instead of tab characters. I was also including spaces before the closing ENDSSH
which was causing the EOF. These changes were a part of my problem, but the final thing that resolved it was removing an additional space character that appeared AFTER my closing ENDSSH
.