ssh command doesnot excute commands in the destination server

Hi All,

I have the below code where Iam connecting from xzur111pap server to xzur0211pap server thru ssh to execute some commands.

ssh xzur0211pap
spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
spaceleft=${spaceleft%\%}
if [[ $spaceleft -gt $danger ]]; then
   echo "ALERT : HUFS(/home $spaceleft)"
exit 0
fi

When I run this Iam successfully connecting to xzur0211pap but the commands are not being executed and the control never comes back to xzur111pap..

Can someone help.

Many thanks in advance.

You know? It does help to know the OS and version for df may have not the same output.. and so understanding what you expect for an output can be tricky:

On HP-UX:

ant:/home/vbe $ df -k /home |tail -1 | awk '{print $5}'

ant:/home/vbe $ df -k /home
/home                  (/dev/vg00/lvol5       ) :   492845 total allocated Kb
                                                    108035 free allocated Kb
                                                    384810 used allocated Kb
                                                        78 % allocation used
ant:/home/vbe $ df -k /home |tail -1 
                                                        78 % allocation used
ant:/home/vbe $ spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
ant:/home/vbe $ 

.
.
Now AIX:
n12:/home/vbe $ df -k /home |tail -1 | awk '{print $5}'
4795
n12:/home/vbe $ spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
n12:/home/vbe $ spaceleft=${spaceleft%\%}
n12:/home/vbe $ echo $spaceleft
4795

Hi its an a linux machine..

Not user I understand your request...
Is it a script in which you put ssh then the rest of commands?
I which case I would say once ssh got executed you have also a new shell on remote box that knows nothing of what is following...
You should rewrite your script and remove the ssh part, look at the man pages of ssh for the correct syntax to pass when wanting to pass commands