I am not sure what I am doing wrong here, I did some research and only confused myself further. Any help would be greatly appreciated. I need to make this work for work tomorrow.
There are only 34 lines of code in this script, yet its complaining about line 35
Here is the code:
#!/bin/bash
VUE_SEND_DIR=/blah/send
VUE_GET_DIR=/blah/receive
LC_GET_DIR=/usr/public/blah/blah/CDK/get
LC_SEND_DIR=/usr/public/blah/blah/CDK/send
PS3='Let me know what you would like to do'
LIST="Pull Send EXIT"
select OPT in $LIST
do
if [ $OPT = "Pull" ] &> /dev/null
then
sftp blah@sftp.blah.com <<EOF
cd $VUE_SEND_DIR
lcd $LC_GET_DIR
mget *
exit
EOF
elif [ $OPT = "Send" ] &> /dev/null
then
sftp blah@sftp.blah.com <<EOF
cd $VUE_GET_DIR
lcd $LC_SEND_DIR
mget *
exit
EOF
elif [ $OPT = "END" ] &> /dev/null
then
exit 0
fi
done
Before you forget, you should put that into your ~/.exrc so vi always has it on your login!
One of my vi interview question answers was, to see hidden characters on a one time basis, ":.l". I missed that one, but they hired me.
I use "cat -vte" on problem files, too, to see control characters and spaces/tabs at end of line. It even works to look around in binary file streams without linefeeds.
It feels easier to see problems with "cat -vte" than with the more aggressive "od -bc", where lines are merged into a rectangle of dump.
I use << rarely, not because Imight forget that the control string must be on a line absolutely by itself, but because I like the finer control and the pipe-friendly data-up-front flavor of echo pipe to achieve the same end:
echo 'No $meta char in here
but \\.
'"You get expansion in here for $sure
"' but not $(here)!
' | whatever | more_stuff | more_yet | ssh2 some_host ksh
I usually start out my echo with the single quote and for stuff that needs expansion use the double quotes, like "$variable_name" or nothing, like $( command inline data generator ), which is somewhat implicitly protected.
This works especially well if you want the commands to run on a remote host, since the single quote keeps all the remote metadata unexpanded without individual escapes. Why write two scripts, when you can keep all the process in one, in sync.?