LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Error Executing the script. (https://www.linuxquestions.org/questions/linux-newbie-8/error-executing-the-script-820909/)

pinga123 07-20-2010 01:14 AM

Error Executing the script.
 
Code:

# 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


Code:

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.

Code:

# ./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 .
Code:

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:

Tinkster 07-20-2010 01:18 AM

That can't be the same script - it doesn't have 85 lines to begin with.

pinga123 07-20-2010 01:31 AM

Quote:

Originally Posted by Tinkster (Post 4039074)
That can't be the same script - it doesn't have 85 lines to begin with.

I m sorry . I had removed the commented part from the script. 85 line points to
Code:

MACHINEEXISTFLAG=$(ssh -T -q -n root@$1 xm list | grep $2)
I find it hard to understand why this is happening?

Tinkster 07-20-2010 01:49 AM

The script is called .cgi ... to me that suggests that it's run
as part of a web-app. As such it will be run by the apache user
(httpd, apache, websomething, ...) who won't have them in the
PATH. Try specifying the full paths for both commands.

pinga123 07-20-2010 01:55 AM

Quote:

Originally Posted by Tinkster (Post 4039106)
The script is called .cgi ... to me that suggests that it's run
as part of a web-app. As such it will be run by the apache user
(httpd, apache, websomething, ...) who won't have them in the
PATH. Try specifying the full paths for both commands.

This is just a test file .Even after renaming .cgi to sh and running the scriptlet results in the same error.

pinga123 07-20-2010 03:06 AM

I got the error .
I had used PATH as a variable for storing application level information.

Tinkster 07-20-2010 01:32 PM

Quote:

Originally Posted by pinga123 (Post 4039161)
I got the error .
I had used PATH as a variable for storing application level information.

LOL ...

Well done for finding it, anyway ;}

And thanks for marking it as solved.


All times are GMT -5. The time now is 08:36 PM.