Operating System - HP-UX
1755723 Members
3226 Online
108837 Solutions
New Discussion юеВ

unusual problem with shell scripts

 
SOLVED
Go to solution
amonamon
Regular Advisor

unusual problem with shell scripts

helloo..

On my solaris I have 2 scripts...one is very simple just init 6

while the other is more complex..

both scripts work just fine but I have some aplication done on my remote windows and I can not execute init 6 script...but other scripts can be executed..any ides??
21 REPLIES 21
Peter Godron
Honored Contributor

Re: unusual problem with shell scripts

Hi,
can you please confirm/clarify:
1. These scripts are on a Solaris platform
2. If they are on a Solaris platform, why do you mention remote windows.
3. You say both scripts work fine, but then that you can not execute the init 6 script.


For point 3.: Have you checked the execute permissions with 'ls -l'
amonamon
Regular Advisor

Re: unusual problem with shell scripts

right i was confusing..
there are 2 ways to reach those scripts both from windows machine:

1. from emulator like putty both scripts work perfect i can restart machine..

2. using php and telenet class I can execute one script but script with init 6 can not be executed..

PHP code is OK I know that...and in all ways I am root.
Peter Nikitka
Honored Contributor

Re: unusual problem with shell scripts

Hi,

I'm shure you can tell us the error message, wen you try to execute that script.
'init 6' is a call for reboot, so:
- what is the name of the script calling 'init 6'
- what else is found in that script?


mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Ralph Grothe
Honored Contributor

Re: unusual problem with shell scripts

Since you mentioned PHP,
did I get it right that you want from your remote Windows PC (from a browser?) reboot your Solaris server by an init 6 through some sort of CGI script?
So is there a webserver which is supposed to execute the PHP involved?
For security reasons you wouldn't want the webserver on the Solaris box being run as root.
Madness, thy name is system administration
amonamon
Regular Advisor

Re: unusual problem with shell scripts

ok I have script restartNode:

#!/bin/ksh


responce="US"
if [ $responce == "US" ]; then
# echo "cao"
# ./restart214
init 6
#shutdown -i6 -g0 -y
echo "has not been created">>kFILE
else
echo "$dir has not been created"
fi


if I execute it via putty it restarts machine..and works perfect..
but with PHP I just can not execute this script all others can be executed..
to be more precised:

script

#!/bin/ksh


responce="US"
if [ $responce == "US" ]; then
# echo "cao"
# ./restart214
# init 6
#shutdown -i6 -g0 -y
echo "has not been created">>kFILE
else
echo "$dir has not been created"
fi

can be executed via PHP
so if I put # before init 6 it works even via PHP(telnet from windows) but if I remove # it does not work..

strange...
Peter Nikitka
Honored Contributor

Re: unusual problem with shell scripts

Hi,

- try to catch the error
- call init with pathname


#!/bin/ksh
responce="US"

exec 2>/tmp/shutt.err

if [ $responce == "US" ]; then
# echo "cao"
# ./restart214
/usr/sbin/init 6
#shutdown -i6 -g0 -y
echo "has not been created">>kFILE
else
echo "$dir has not been created"
fi

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
amonamon
Regular Advisor

Re: unusual problem with shell scripts

I tryed to catch errors..it creates error file but no errors inside that file..

Peter Nikitka
Honored Contributor

Re: unusual problem with shell scripts

Hi,

modify script to get traces:

#!/usr/bin/ksh -x
exec 2>/tmp/shutt.err
responce="US"

if [ $responce == "US" ]; then
echo "ciao"
# ./restart214
/usr/sbin/init 6
#shutdown -i6 -g0 -y
echo "has not been created">>kFILE
else
echo "$dir has not been created"
fi

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
amonamon
Regular Advisor

Re: unusual problem with shell scripts

Peter I did that I get empty file errors.err