Using wait command in heredoc
For the following tiny wait script for which the function was added to the bash profile:
chai() {
expect <<- EOF
spawn ssh myuser@myserver
expect ': $'
send 'mypassword\r'
EOF
}
We get:
bash: /etc/profile: line 409: syntax error: unexpected end of file
What's wrong with this script?
+3
source to share
1 answer
I usually expected the heredoc terminator (EOF) to be at the beginning of the line, eg.
chai() {
expect <<- EOF
spawn ssh myuser@myserver
expect ': $'
send 'mypassword\r'
EOF
}
I see you are using <<-
and from the linked document:
Option - to mark document limit string here (<<-LimitString) suppresses leading tabs (but not spaces) in output. It can be useful to make the script more readable.
so you have to check the script to see if you have any TAB
preceding your commands. EOF obeys the same rules.
cat <<-ENDOFMESSAGE
This is line 1 of the message.
This is line 2 of the message.
This is line 3 of the message.
This is line 4 of the message.
This is the last line of the message.
ENDOFMESSAGE
# The output of the script will be flush left.
# Leading tab in each line will not show.
+1
source to share