[solved] Error Executing the script.

# cat SERVERNAMES
10.180.8.231
10.180.8.232
10.180.8.233
10.180.8.234
10.180.8.235
10.180.8.236
10.180.8.237
10.180.8.238
10.180.9.239
fn_Exit()
{
echo "Machine Doesnt exist"
exit 1 #exit shell script
}

echo "Please Enter Guest Name:"
read VM_GUEST

PATH=$(ssh -ttq root@10.180.8.231 find /var/ovs/mount -name *$VM_GUEST)
if [ -z "$PATH" ]
then
fn_Exit
else
echo "Machine Exists"
fi

fn_VMServerSearch()
{
MACHINEEXISTFLAG=$(ssh -T -q -n root@$1 xm list | grep $2)
if [ ! -z "$MACHINEEXISTFLAG" ]
then
echo "Machine $VM_GUEST Is Found At $1"
fi
}

#To Check The ServerName of Guest Machine.
while read line
do
fn_VMServerSearch "$line" "$VM_GUEST"
done < SERVERNAMES

Whenever i execute the above script i m getting following error.

# ./vm_finder_mod_V2.cgi
Please Enter Guest Name:
WIN2003-SP2
Machine Exists
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found
./vm_finder_mod_V2.cgi: line 85: ssh: command not found
./vm_finder_mod_V2.cgi: line 85: grep: command not found

However If i execute the code by excluding .

PATH=$(ssh -ttq root@10.180.8.231 find /var/ovs/mount -name *$VM_GUEST)
if [ -z "$PATH" ]
then
fn_Exit
else
echo "Machine Exists"
fi

I get the proper output.

What can be the issue?
I m confuesed.:rolleyes:

I had removed the commented part from the script there fore 85 line points to line 14 in the code.
i.e.

MACHINEEXISTFLAG=$(ssh -T -q -n root@$1 xm list | grep $2)

Hi.

Is there any reason why you chose "PATH" as your variable name?

I would certainly change that.

# SSH, etc. is in the path at this point...
PATH=$(ssh -ttq root@10.180.8.231 find /var/ovs/mount -name *$VM_GUEST)
# What is the value of PATH now?
if [ -z "$PATH" ]
then
fn_Exit
else
echo "Machine Exists"
fi

fn_VMServerSearch()
{
# But probably not at this point...
MACHINEEXISTFLAG=$(ssh -T -q -n root@$1 xm list | grep $2)
if [ ! -z "$MACHINEEXISTFLAG" ]
then
echo "Machine $VM_GUEST Is Found At $1"
fi
}

#To Check The ServerName of Guest Machine.
while read line
do
fn_VMServerSearch "$line" "$VM_GUEST"
done < SERVERNAMES

How fool i m ! Thank you very much .

---------- Post updated at 02:32 AM ---------- Previous update was at 02:31 AM ----------

how would i mark the tread as solved?