Problem: sudo doesn't work in Shell Script Test.
Posted: Thu May 09, 2013 3:27 am
Dear KS-Soft:
I changed rma(linux) file owner group and access permissions to the user "monitor",and start rma by this user:
-rwx-r-r-- 1 monitor monitor 809 2010-01-20 cpu.sh
-rwx-r-r-- 1 monitor monitor 12987 2012-10-23 INSTALL
-rwx-r-r-- 1 monitor monitor 4641 2012-10-23 LICENSE
-rw-r--r-- 1 monitor monitor 206 04-19 17:31 log.txt
-rwx-r-r-- 1 monitor monitor 787 2007-02-22 proccnt.sh
-rwx-r-r-- 1 monitor monitor 543 2007-02-22 proclist.sh
-rwx-r-r-- 1 monitor monitor 2996 2012-10-23 README
-rwx-r-r-- 1 monitor monitor 224268 11-19 20:50 rma
-rwx-r-r-- 1 monitor monitor 7709 04-19 12:17 rma.ini
drwxr-xr-x 2 monitor monitor 4096 05-09 15:53 tmp
And I use Shell Script(Linux) method to perform some tests.All command in my scripts can be executed by user "monitor".
Some scripts works fine,but the other scripts including command "sudo" does not work.
E.g.
=====================
#!/bin/sh
COMMAND=/opt/IBM_DS/client/SMcli
if [ $# -ge 2 ]
then
CTRLAIP=$1
CTRLBIP=$2
###HERE: sudo doesn't work!!!!!
RESULT=$(sudo $COMMAND $CTRLAIP $CTRLBIP -c "show storageSubsystem healthStatus;")
case "$RESULT" in
*failure*)
echo 'ScriptRes:Bad:Failure'
exit
;;
*optimal*)
echo 'ScriptRes:Ok:Optimal'
exit
;;
*)
echo 'ScriptRes:Unknown:Unkown response from SMcli'
exit
;;
esac
else
echo 'ScriptRes:Unknown:not enough parameters specified'
fi
=====================
I changed rma(linux) file owner group and access permissions to the user "monitor",and start rma by this user:
-rwx-r-r-- 1 monitor monitor 809 2010-01-20 cpu.sh
-rwx-r-r-- 1 monitor monitor 12987 2012-10-23 INSTALL
-rwx-r-r-- 1 monitor monitor 4641 2012-10-23 LICENSE
-rw-r--r-- 1 monitor monitor 206 04-19 17:31 log.txt
-rwx-r-r-- 1 monitor monitor 787 2007-02-22 proccnt.sh
-rwx-r-r-- 1 monitor monitor 543 2007-02-22 proclist.sh
-rwx-r-r-- 1 monitor monitor 2996 2012-10-23 README
-rwx-r-r-- 1 monitor monitor 224268 11-19 20:50 rma
-rwx-r-r-- 1 monitor monitor 7709 04-19 12:17 rma.ini
drwxr-xr-x 2 monitor monitor 4096 05-09 15:53 tmp
And I use Shell Script(Linux) method to perform some tests.All command in my scripts can be executed by user "monitor".
Some scripts works fine,but the other scripts including command "sudo" does not work.
E.g.
=====================
#!/bin/sh
COMMAND=/opt/IBM_DS/client/SMcli
if [ $# -ge 2 ]
then
CTRLAIP=$1
CTRLBIP=$2
###HERE: sudo doesn't work!!!!!
RESULT=$(sudo $COMMAND $CTRLAIP $CTRLBIP -c "show storageSubsystem healthStatus;")
case "$RESULT" in
*failure*)
echo 'ScriptRes:Bad:Failure'
exit
;;
*optimal*)
echo 'ScriptRes:Ok:Optimal'
exit
;;
*)
echo 'ScriptRes:Unknown:Unkown response from SMcli'
exit
;;
esac
else
echo 'ScriptRes:Unknown:not enough parameters specified'
fi
=====================