[sudo-users] getting a syntax error when I run a scritp via sudo

Robert Morris Robert.Morris at unionbank.com
Thu Jun 4 15:58:24 MDT 2015


I have a script that needs to be run as mtsadm
And it works without any problems when I run it from the mtsadm account

cat /usr/local/intranet/areas/uat/bmcpatrol/mon_linestat_ind.sh

. /usr/intranet/isd50/nex/90/bin/nexrc
area isd > /dev/null 2>&1
echo -n "$1-$2 ";linecmd -line $2 -bank ubk -sh | grep LINECMD | grep UP | wc -l

------------------------------------------------------------------------------

$     id
uid=235(mtsadm) gid=269(mts) groups=351(gfttest)


$   /usr/local/intranet/areas/uat/bmcpatrol/mon_linestat_ind.sh
-       13                   << this is what I am looking for

----------------------------------------------------------------
>From root I  su - patrol


# su - patrol
which: 0652-141 There is no vim in /usr/xpg4/bin /opt/bmc/Patrol3/UNSUPPORTED/bin /opt/CA/SharedComponents/JRE/1.4.2/bin /usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin /usr/java130/jre/bin /usr/java130/bin /usr/local/bin /usr/local/scripts /opt/CA/SharedComponents/bin /opt/bmc/Patrol3/UNSUPPORTED/bin /opt/bmc/Patrol3/AIX5.3.0.0-32/best1/7.3.00/bgs/bin /opt/bmc/Patrol3/AIX5.3.0.0-32/best1/7.3.00/bgs/scripts /bin /WebCentral/jakarta-tomcat/bin /apache2/bin.
.profile[64]: test: 0403-004 Specify a parameter with this command.

Env is...
vi: ksh alias not found.
PATROL_ROOT is
PATROL_HOME is /opt/bmc/Patrol3/UNSUPPORTED
BEST1_HOME is /opt/bmc/Patrol3/AIX5.3.0.0-32/best1/7.3.00
CATALINA_HOME is



$    id
uid=230(patrol) gid=230(bmc) groups=0(system),4(adm),413(webbts)

Here are the sudo rules that the patrol account has


$    sudo -l
User patrol may run the following commands on this host:
    (root) NOPASSWD: /sbin/ethtool
    (root) NOPASSWD: /sbin/hpasmcli
    (root) NOPASSWD: /usr/sbin/hpacucli ctrl all show*
    (root) NOPASSWD: /bin/su - mtsadm
    (mtsadm) NOPASSWD: /usr/local/intranet/areas/uat/bmcpatrol/mon_linestat_ind.sh
    (mtsadm) NOPASSWD: /usr/local/intranet/areas/uat/bmcpatrol/mon_journal.sh
    (mtsadm) NOPASSWD: /usr/local/intranet/areas/uat/bmcpatrol/mon_trapped.sh


I try to run the script as mtsadm and get the Syntax error


sudo -u mtsadm /usr/local/intranet/areas/uat/bmcpatrol/mon_linestat_ind.sh
/usr/local/intranet/areas/uat/bmcpatrol/mon_linestat_ind.sh: Syntax error at line 86: `}' not expected.

I know that I am doing something wrong but what
The script runs as mtsadm
But why do I get a Syntax error?

Robert E. Morris
Unionbank



******************************************************************************
This communication (including any attachments) may contain privileged or
confidential information intended for a specific individual and purpose, 
and is protected by law.  If you are not the intended recipient, you should
delete this communication and/or shred the materials and any attachments and
are hereby notified that any disclosure, copying, or distribution of this
communication, or the taking of any action based on it, is strictly prohibited.

Thank you.



More information about the sudo-users mailing list