1

I've got a startup/stop script provided for Tivoli Workload Scheduler in which it will start/stp[ the TWS services in IBM i.

    # CHECK ROOT USER
    WHO=`id | cut -f1 -d" "`
    if [ "$WHO" = "uid=0(root)" ]
    then
    su TWSSVC -c "/etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop"
    exit $?
    fi

    /etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop
    exit $?

Problem with this is that, in OS/400 the equivalent of root is QSECOFR, so I've amended the line

 if [ "$WHO" = "uid=0(root)" ]

to

 if [ "$WHO" = "uid=0(QSECOFR)" ]

then i got an error on the following line:

 su TWSSVC -c "/etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop"

 /TWSSVC/TWS/ShutDownLwa: 001-0019 Error found searching for command su. No such path or directory.   

How do I change to script such that, when it is QSECOFR, it will su into TWSSVC and trigger the start/stop script? I'm not very familiar with OS400. I'm triggering this script in qsh environment.

brian
  • 10,619
  • 4
  • 21
  • 79

1 Answers1

0

you can try the following;

sudo TWSSVC -c "/etc/rc.d/init.d/tebctl-tws_cpa_agent_TWSSVC stop"

Tell me how it goes.

nu1silva
  • 149
  • 1
  • 9
  • Hi nu1silva, `/TWSSVC/TWS/ShutDownLwa: 001-0019 Error found searching for command sudo. No such path or directory.` –  Aug 02 '13 at 06:06
  • what environment are you on? (Ubuntu/CentOS/RHEL)? does su or sudo in terminal work properly? – nu1silva Aug 02 '13 at 06:20
  • Hi nu1silva, this is a IBM i machine running on OS/400, i ran the commands in Qshell. –  Aug 02 '13 at 07:06
  • sorry, my bad didn't read the subject properly. anyway this is totally different from Unix/Linux where you use su/sudo. you might have to switch to a user who has permission. check this out [QSYGETPH](http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2FQSYGETPH.htm) and this also [serverfault.com](http://serverfault.com/questions/413451/runas-or-sudo-equivalent-on-as400-ibm-iseries). hope it helps – nu1silva Aug 02 '13 at 09:15