The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-19-2007
rubionis rubionis is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 18
IF condition failing in a SSH script

Hi,

I'm ssh-in to a remote machine (ubuntu) and trying to execute a little script in there.The script looks like this:


Code:
ssh user@ubuntu <<EOF
cd ~/test
ls -l
echo "Continue counting files starting with a`s ?"
read answer
if [ "$answer" = y ]
then 
ls -l a*
else
exit
fi
EOF

Now everything works fine up to the IF test. The script seems to escape the read command, (doesn't prompt ), and all the rest of the IF gets ignored. It shows an error near the "then" part. I tried building a local script in the remote machine and recalling that from the SSH script, but that seems to fail too. Built a simple script with the case condition but that seems to have an error - "unexpected end of file", even though everything looks correct,( checked even with od -c for any hidden character)
In other words every simple script that I built with a test condition in a SSH script
seems to fail.

Anybody any ideas ?

And in general, is there a rule that I should keep in mind when executing a test condition in a remote machine thru a SSH script ?

Last edited by rubionis; 04-15-2008 at 06:42 PM.. Reason: added code tags