From: lora on
Hello all,

I've got the bash script below that I've placed in /etc/init.d and the
appropriate soft link in the rc.d 5 directory.

These scripts run as root after I do init 6.

When this runs after I reboot the LINUX box, it's able to execute the
part that dumps the contents of the environment variable $P4 to the
snmTest file.

However, it's not able to launch the myshell process.

When the same script is run as root via the command line, it works
fine.

The same script runs fine when I do:
sudo ./snmsrv

What could be wrong?

Thanks



#!/bin/bash
echo RSHServer

if [ `id -u` -eq 0 ]; then

echo "running as root"
if ps aux | grep '[/]StartMenu/snmsrv.tcl'
then
echo "RSH Server already running...will not restart"
else
echo "Will restart RSH server..."
su testuser -c ". ~testuser/.profile ; myshell & "
su testuser -c ". ~testuser/.profile ; echo \$P4 >>
~testuser/snm
Test ; myshell -cmd \"source \$P4/myscript.tcl \" & "

fi

else
echo "Running in user mode. Skipping"

fi

From: Eric on
On 2010-02-08, lora <anjela_pat(a)yahoo.com> wrote:
> Hello all,
>
> I've got the bash script below that I've placed in /etc/init.d and the
> appropriate soft link in the rc.d 5 directory.
>
> These scripts run as root after I do init 6.
>
> When this runs after I reboot the LINUX box, it's able to execute the
> part that dumps the contents of the environment variable $P4 to the
> snmTest file.
>
> However, it's not able to launch the myshell process.
>
> When the same script is run as root via the command line, it works
> fine.
>
> The same script runs fine when I do:
> sudo ./snmsrv
>
> What could be wrong?
>
> Thanks
>
>
>
> #!/bin/bash
> echo RSHServer
>
> if [ `id -u` -eq 0 ]; then
>
> echo "running as root"
> if ps aux | grep '[/]StartMenu/snmsrv.tcl'
> then
> echo "RSH Server already running...will not restart"
> else
> echo "Will restart RSH server..."
> su testuser -c ". ~testuser/.profile ; myshell & "
> su testuser -c ". ~testuser/.profile ; echo \$P4 >>
> ~testuser/snm
> Test ; myshell -cmd \"source \$P4/myscript.tcl \" & "
>
> fi
>
> else
> echo "Running in user mode. Skipping"
>
> fi
>

Rather than echoing P4, echo PATH. I bet you'll find that wherever
myshell is, it's not on that PATH.

The answer - put the full path to myshell in the script instead of just
the name!

E.
From: mop2 on
On Mon, 08 Feb 2010 19:37:45 -0200, lora <anjela_pat(a)yahoo.com> wrote:

> Hello all,
>
> I've got the bash script below that I've placed in /etc/init.d and the
> appropriate soft link in the rc.d 5 directory.
>
> These scripts run as root after I do init 6.
>
> When this runs after I reboot the LINUX box, it's able to execute the
> part that dumps the contents of the environment variable $P4 to the
> snmTest file.
>
> However, it's not able to launch the myshell process.
>
> When the same script is run as root via the command line, it works
> fine.
>
> The same script runs fine when I do:
> sudo ./snmsrv
>
> What could be wrong?
>
> Thanks
>
>
>
> #!/bin/bash
> echo RSHServer
>
> if [ `id -u` -eq 0 ]; then
>
> echo "running as root"
> if ps aux | grep '[/]StartMenu/snmsrv.tcl'
> then
> echo "RSH Server already running...will not restart"
> else
> echo "Will restart RSH server..."
> su testuser -c ". ~testuser/.profile ; myshell & "
> su testuser -c ". ~testuser/.profile ; echo \$P4 >>
> ~testuser/snm
> Test ; myshell -cmd \"source \$P4/myscript.tcl \" & "
>
> fi
>
> else
> echo "Running in user mode. Skipping"
>
> fi
>
>



Try log files to see errors, for main and sub routines:

.....
echo "Will restart RSH server..."
exec 2>/tmp/rc.log # <======
su testuser -c "exec 2>/tmp/sub.log; . ~testuser/.profile ; myshell & " # <==
su testuser -c ". ~testuser/.profile ; echo \$P4 >> ~testuser/snm
.....