saibsk
asked on
running shell script inside a cgi script
I have a cgi script written using shell scripting. I want to execute another shell script inside the cgi script to setup the global environment.
Inside the CGI script
logFileName=${LOGSDIR}/inf o.log
. /scripts/global_setup.env
Inside the global_setup.env
SCRIPTDIR=monitor/scripts
LOGSDIR=monitor/logs
But I am not able to run the env script inside the cgi script as shown above. Could you please advise?
Inside the CGI script
logFileName=${LOGSDIR}/inf
. /scripts/global_setup.env
Inside the global_setup.env
SCRIPTDIR=monitor/scripts
LOGSDIR=monitor/logs
But I am not able to run the env script inside the cgi script as shown above. Could you please advise?
What happens? Do you get any error? Make sure to give same permissions to this script as the cgi script.
Did you mean to do
. /scripts/global_setup.env
logFileName=${LOGSDIR}/inf o.log
. /scripts/global_setup.env
logFileName=${LOGSDIR}/inf
ASKER
global_setup.env has the same perms as the cgi script. And I did make the changes as above. When I try executing the cgi script through the console it works fine. I executed using the command ksh global_setup.env. But on the browser it throws an http 500 internal server error. I dont have access to the error log.
500 is very generic error but it could be due to the fact that you are trying to access ${LOGSDIR} before it is set. That statement would probably not throw any error but it would set the logFileName incorrectly and that may later produce error. Change the order of these statements as suggested by ozo i.e. invoke the global_setup.env before setting logFileName.
ASKER
i made the change. Throws the same error.
Does a simple cgi script work fine? A simple script as simple as
echo "Hello World"
?
echo "Hello World"
?
ASKER
if I remove the line in cgi script the cgi script works fine
Which line? The one that calls /scripts/global_setup.env? If so it must be something to do with permissions. Do
ls -l /full/path/to/cgifile
ls -l /scripts/global_setup.env
and confirm same permissions on both. You may have to verify list access control list also in case ls -l shows same permissions. Use lsacl -l filename to verify list access contol.
ls -l /full/path/to/cgifile
ls -l /scripts/global_setup.env
and confirm same permissions on both. You may have to verify list access control list also in case ls -l shows same permissions. Use lsacl -l filename to verify list access contol.
ASKER
I did check ls -l for the env script and cgi script it shows 777 for both. Additionally for the command lsacl -l it shows up this message. ksh: lsacl: not found.
Is there anything else inside
/scripts/global_setup.env
?
is there anything else Inside the CGI script?
/scripts/global_setup.env
?
is there anything else Inside the CGI script?
Where are those 2 files relative to each other? Also does global_setup.env contain only the 2 statements that you showed?
ASKER
Actuall I want to globalize the environment so instead of setting these two lines in each file:
SCRIPTDIR=monitor/scripts
LOGSDIR=monitor/logs
I want to write a shell script which contains these lines. And execute that in the cgi script.
Currently i have made the change in the env script just to have this code
#!/bin/ksh
echo Content-type: text/html
echo "I am inside GLOBAL"
CGI script code:
#!/bin/ksh
echo Content-type: text/html
. /apps/SunOne/web61sp2/docs /coe/coe_m onitor/scr ipts/coeGl obal.env &
Yet it shows up with the 500 error. Probably issue with the invocation of the env script.
Please advise
SCRIPTDIR=monitor/scripts
LOGSDIR=monitor/logs
I want to write a shell script which contains these lines. And execute that in the cgi script.
Currently i have made the change in the env script just to have this code
#!/bin/ksh
echo Content-type: text/html
echo "I am inside GLOBAL"
CGI script code:
#!/bin/ksh
echo Content-type: text/html
. /apps/SunOne/web61sp2/docs
Yet it shows up with the 500 error. Probably issue with the invocation of the env script.
Please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try
echo Content-type: text/html
echo
. /apps/SunOne/web61sp2/docs /coe/coe_m onitor/scr ipts/coeGl obal.env
echo Content-type: text/html
echo
. /apps/SunOne/web61sp2/docs