Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

su - -c within script issue

Status
Not open for further replies.
Nov 6, 2001
77
US
Hi

From root, I issue the following command:
su - sccadm "-c /U/bin/scc.shutdown -kK"

it does not run the scc.shutdown command, instead stops at sccadm home directory. I can't figure out why it stops.

Once I'm user sccadm, the shutdown command does run successfully, but I would like it to script this process. The userid was created by the vendor.

thanks for any help
 
[tt]su - sccadm -c "/U/bin/scc.shutdown -kK"[/tt]

I would think...

HTH,

p5wizard
 
I tried it that way too. Also tried it without the ". Every way stops after the su - sccadm.
 
Try creating a script /U/bin/scc.shutdown.ksh which looks like
Code:
#!/bin/ksh -xv
/U/bin/scc.shutdown -kK
And then try
Code:
su - sccadm -c /U/bin/scc.shutdown.ksh
the -xv flags on ksh should show what's happening.

Ceci n'est pas une signature
Columb Healy
 
same problem. Since this script doesn't have the su - sccadm, it is doing a shutdown. My thought is that the vendor has something the the profile of sccadm that is preventing anything from running after the su.

shutapps
#!/bin/ksh -xv
/U/bin/scc.shutdown -kK
+ /U/bin/scc.shutdown -kK


Verify environment:

OWNER=scc
UDIR=/U
IPCDIR=/home/tmp/ipcs//U


ALL PROCESSES IN THIS ENVIRONMENT WILL BE TERMINATED !!!

You have 10 seconds to stop execution with Ctrl-C ..^C[klehr]soft1:/data/sc
ripts# su - sccadm -c /U/bin/scc.shutdown.ksh
soft1:/U/user/sccadm>
[klehr]soft1:/data/scripts# su - sccadm -c "/U/bin/scc.shutdown.ksh"
soft1:/U/user/sccadm>
[klehr]soft1:/data/scripts# su - sccadm "-c /U/bin/scc.shutdown.ksh"
soft1:/U/user/sccadm>

I added the su to the script:
soft1:/data/scripts# shutapps
#!/bin/ksh -xv
su - sccadm -c "/U/bin/scc.shutdown -kK"
+ su - sccadm -c /U/bin/scc.shutdown -kK
soft1:/U/user/sccadm>
 
Can you su from command line and post the output of env

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
OK, what happens when you run this:

Code:
su - sccadm -c date

su - sccadm -c hostname

su - sccadm <<eof_su
date
hostname
eof_su

su - sccadm <<eof_su
/U/bin/scc.shutdown -kK
eof_su


HTH,

p5wizard
 
The env info is fist, then the info fo p5wizard is at the end.

soft1:/U/user/sccadm> env
_=/usr/bin/env
ESCDELAY=3600
LOCINITFILE=/U/term/kea/softlab.but
GUIBIN=/U/bin
HAS_PATH=N
RESTART_SERVER_ONLY=N
USESHM=YYYYYY
LANG=en_US
VBROKER_ADM=/usr/local/BorlandVisiBroker64_521/adm
HAS_GINV=N
HAS_BCL=N
SCC_LANG=
LOGIN=sccadm
SKIPSEC=skipdb
IPCDIR=/home/tmp/ipcs//U
HAS_GCMN=Y
RPTD_HOST=soft1
_TRACELEVEL_=0
HAS_TSA=N
newport=tomcathttpMAIN
ONES=
VISTADIR=/U/tmp/vista
HAS_GIMG=N
SCRIPTPARAM=/U/dict/lib/hosparams/RWJUH/Scriptparam.txt
JAVA_OPTS=-Xms64M -Xmx512M
VER_ODBC=7.0.0.3.2
VER_LABSRVC=4.0.0.6.1
WPIPCDIR=/home/tmp/ipcs//U
SHLIB_PATH=/U/slib/RWJUH:/U/slib/addons:/U/slib:/usr/lib:/lib:/usr/IBMIHS//lib
HAS_BSA=Y
SCCEUID=scc
VER_LABMIC=4.0.3.8.5
MTSLIB_DIR=/U/slib/mtslib
VER_GLAB_SHORT=4.0
VER_GSIE=4.2.0.3.2
FILE=/etc/services
HAS_GMOL=N
BINPATH=/U/lnew/bin
PATH=/U/ssc/bin:/usr/local/BorlandVisiBroker64_521/bin:/usr/java14_64/bin:/usr/j
ava14_64/jre/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java14
/jre/bin:/usr/java14/bin:/data/scripts:.:/etc/scc:/usr/local/scc/bin:/U/bin:/U/l
new/bin:/U/misc/bin
VER_GLAB=4.0.3.8.6
SCC_URL_MAIN=MPD_BANNER=
VBROKER_IMPL_PATH=/U/dict/corba
VER_GMIC=4.0.3.8.6
TRTMP=/U/trace/trtmp
LC_ALL=C
GMICPARAM=/U/dict/mic/hosparams/gmicparam.txt
SCC_RELEASE=4.0.2.14.4_HIPAA
GCMN=cmn
MPISPARAM=/U/dict/mpis/hosparams/RWJUH/Mpisparam.txt
DBLOG=/U/tmp/log/
LOCKTIME=3000
VER_GMIC_SHORT=4.0
VBROKER_IMPL_NAME=impl_rep_cmn
HTTP_PORT=25015
OSAGENT_PORT=14000
NSDIR=/U
RMID_PORT=25049
SCC_URL_AUX=OAD_PARAM=-kill
DBPATH=/U/db
VER_BSA=2.0.1.0.1
REPGEN=/U/dict/lab/sql//repgen
HAS_LAB=Y
VER_GUICMN=GuiCmn2.10.0
HAS_MIC=Y
SCCLISAUX=soft2
BACKUPPATH=/U/user/backup
TOMCAT_SEC_MANAGER_CLASS_NAME=com.scc.sie.securitymanager.FakeSecurityManager
ALDIRECTORY=/U/arsched/output
GRAPHINFO=/U/dict/lab/query
HAS_BB=Y
HAS_GPRS=N
_FTOK_MINOR=ON
LC__FASTMSG=true
SDIR=/U
CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.28
MAINSYS=soft1
SCCODBC_USER_PASSWD=scc
APACHE_BASE=/U/apache
REPDIR=/U/dict/lab/sql//reps
GCMNPARAM=/U/dict/lib/hosparams/gcmnparam.txt
RMI_HOST=soft1
RMI_PORT=25047
LIBCFG=/U/dict/gui/cmn/config/libcfg.txt
ENV_PREFIX=
HAS_AR=N
HAS_SQRR=N
SMBPATH=/U/dict/odbc
RPTD_ID=MAIN
HISTFILE=/U/user/sccadm/.log/.SCCsh
CLASSPATH=/U/bin/sie/commserver.jar:.:/U/bin/cmn/jclasses/jgl3.1.0.jar:.:/usr/lo
cal/BorlandVisiBroker64_521/lib/vbjorb.jar:/usr/local/BorlandVisiBroker64_521/li
b/lm.jar:/usr/local/BorlandVisiBroker64_521/lib/vbsec.jar:/U/slib/jcorbaLib.jar
BRSDIR=/U/dict/cmn/browser
HAS_GSIE=Y
LOGNAME=sccadm
HAS_GRAD=N
MSITE=
TMSID=RWJUH
HAS_GLAB=Y
VER_BB=23.1.2.9.1
HAS_GMIC=Y
HAS_GHSW=N
CMNTRC=/U/trace/trtmp/trace/cmn
MAIL=/usr/spool/mail/sccadm
VER_INTSRVC=4.1.0.15.1
SIETRC=/U/trace/trtmp/trace/sie
SIEDATADIR=/U/db/dat/I/HIS/SIEDATA
HAS_GRPT=N
APACHE_PORT=25011
MLABPARAM=/U/dict/mic/hosparams/RWJUH/Labparam.txt
HOSTNAME=soft1
SCCLISMAIN=soft1
HAS_WLD=N
VER_GUILAB=SoftLab4.0
GLABPARAM=/U/dict/lab/hosparams/glabparam.txt
GUI=gui
LOCPATH=/usr/lib/nls/loc
DBNOTRANS=
VER_GUIMIC=SoftMic4.0
HAS_ODBC=Y
PS1=soft1:$PWD>
LABBIN=/U/bin/lab
MICBIN=/U/bin/mic
HIS_PERLIB=/U/dict/his/perlib
COMTRC=/U/trace/trtmp/trace/sie/comm
DUAL_DEPLOYMENT=cmn lab mic sie
HAS_GPAT=N
AIXTHREAD_STK=1000000
SIE_CUSTOM_DIR=/U/dict/gui/sie/custom/RWJUH
HAS_LWS=N
EASYREPS=/U/dict/lib/sql//easyreps
VER_GCMN=4.1.1.7.8
SIE_SERVICES=/etc/services
GUITMP=/U/trace/trtmp/tmp
GSIE=sie
HAS_QC=N
USERD=/U/user
DISABLE_BALANCER=Y
GLAB=lab
HOSNAME=Robert Wood Johnson Univ Hosp
GMIC=mic
SCCODBC_USER=sccodbc
HAS_GCTG=N
USER=sccadm
CLIENT=RWJUH
AUTHSTATE=files
MICPARAM=/U/dict/mic/hosparams/RWJUH/Hosparam.txt
COMPARAM=/U/dict/mail/hosparams/RWJUH/Hosparam.txt
HAS_GHLA=N
SIE_JAVA_HOME=/usr/java14_64
TOMCAT_PORT_HTTP=25015
SCCSHHOME=.sccadm
DT_FORMAT=0
HAS_GSTO=N
HAS_GAWR=N
MULTISITE_LANG_ROLE=YNYNYY
ORBELINEDIR=/usr/local/BorlandVisiBroker64_521
HAS_SSC=Y
HAS_HIS=Y
HAS_LIS=N
HOSPARAM=/U/dict/lib/hosparams/RWJUH/Baseparam.txt
BSAPARAM=/U/dict/bsa/hosparams/RWJUH/BSAparam.txt
CORBAVENDOR=vb
SIE_CUSTOM_PATH=/U/dict/gui/sie/custom/RWJUH
COREDIR=/U/tmp/coredir
OADUTIL=/U/bin/.tools/oad_reg
HAS_LABSRVC=Y
MAJOR_CORBA_VER=5
SHELL=/bin/ksh
ODMDIR=/etc/objrepos
DBFILES=120
APACHE_HOME=/usr/IBMIHS/
HAS_GFLW=N
HIS_CONF=/U/dict/his/RWJUH
VER_INST=4.0.2.32.3
JAVA_HOME=/usr/java14_64
AUXSYS=soft2
CATALINA_BASE=/U/tomcat
VER_ORB=4.1.0.10.1
HISTSIZE=5000
TRACEDIR=/U/trace
HOSAD7=
JORBELINEDIR=/usr/local/BorlandVisiBroker64_521
HOSAD6=
HAS_MQC=N
HOSAD5=08901
SECPARAM=/U/dict/sec/hosparams/RWJUH/Hosparam.txt
PLATFORM=aix
HOSAD4=NJ
GRAPH_RANGE=P
HOSAD3=New Brunswick
HOME=/U/user/sccadm
HIPAA=_HIPAA
SIETMP=/U/trace/trtmp/tmp/sie
HOSAD2=120 Albany St 7th floor
TMPMS=sccadm
MINOR_CORBA_VER=2
VER_HIS=4.0.2.39.2
GCOM_=sie/comm
HOSAD1=Robert Wood Johnson Univ Hosp
SCCORBTRACE=0
HISPARAM=/U/dict/his/hosparams/RWJUH/hisparam.txt
SIMBAINIPATH=/U/dict/odbc
VER_SSC=1.2.0.14.6
SIEDICT=/U/dict/gui/sie
MPD_PS_BANNER=
HAS_BLS=N
HAS_DON=N
BB_HOSPDEF=/U/dict/bb/hosparams/RWJUH/HOSPDEF.R
env_prefix=
MON=/U/SCCsetup/Monitor
AUXS=
MSITE_=
UDIR=/U
BBPARAM=/U/dict/bb/hosparams/RWJUH/BBparam.txt
LABPARAM=/U/dict/lab/hosparams/RWJUH/Hosparam.txt
TERM=vt100
MAX_ALSIZE=500
CMNBIN=/U/bin/cmn
PRODUCTS=cmn lab mic sie
MAILMSG=[YOU HAVE NEW MAIL]
HAS_EXT_SEC=Y
SIEBIN=/U/bin/sie
TMPS=/U/user/sccadm
PASSWD_CRYPTED=Y
RMID_BASEDIR=/U/db/dat/I/HIS/SIEDATA/rmidrep
SIE_QUEUE=/U/db/dat/I/HIS
HAS_INST=Y
DBTAF=/U/tmp/log/
PWD=/U/user/sccadm
ODBC_PORT=25021
NDIR=/U
HAS_INTSRVC=Y
HAS_SGSRVC=N
PRINTERC=/usr/lib/printerc
LABTRC=/U/trace/trtmp/trace/lab
MICTRC=/U/trace/trtmp/trace/mic
HAS_NOE=N
TZ=EST5EDT
COMBIN=/U/bin/sie
VB_HOME=/usr/local/BorlandVisiBroker64_521/bin
OLD_CLASSPATH=
HAS_GAPR=N
HOMEDIR=/U/user/sccadm
SKIP_CORBA_SITE_REGISTRATION=N
ENV=/U/user/sccadm/.kshrc
TOMCAT_SEC_MANAGER_JAR=/U/bin/sie/module/com.scc.sie.securitymanager.jar
HAS_GPHR=N
REPHELP=/U/repdef/repgen.help
GUIDICT=/U/dict/gui
HAS_DORA=N
ENVIRO_NAME=LIVE
REF_CONF=/U/dict/sccreflab/RWJUH
HAS_GARE=N
HAS_GGCM=N
SIEBASEDIR=/U/dict/gui/sie/RWJUH
OAIPADDR=10.130.70.86
DICT=/U/dict
HAS_LMC=N
SOFTSYSID=MAIN
HAS_MPIS=N
HAS_SWS=N
HAS_GSQR=N
TAPE=rmt0
ORBLINEDIR=/usr/local/BorlandVisiBroker64_521
ORBTOOLDIR=/U/bin/.tools
JGLDIR=/U/bin/cmn/jclasses
A__z=! LOGNAME=( env_prefix
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
soft1:/U/user/sccadm>


[klehr]soft2:/home/klehr# su - sccadm -c date
soft2:/U/user/sccadm>
[klehr]soft2:/home/klehr# su - sccadm -c hostname
soft2:/U/user/sccadm>
[klehr]soft2:/home/klehr# su - sccadm <<eof_su
> date
> hostname
> eof_su
Thu Nov 1 08:23:41 EDT 2007
soft2
[klehr]soft2:/home/klehr# su - sccadm <<eof_su
> /U/bin/scc.shutdown -kK
> eof_su


Verify environment:

OWNER=scc
UDIR=/U
IPCDIR=/home/tmp/ipcs//U


ALL PROCESSES IN THIS ENVIRONMENT WILL BE TERMINATED !!!

You have 10 seconds to stop execution with Ctrl-C ..^C
 
Well, isn't that what's supposed to happen?
This isn't the system shutdown script that is started, as that has different output...



HTH,

p5wizard
 
when I do the su - sccadm <<su etc yes it works this way. I just wonder why it doesn't work the other way, with the -c. I do have a call into the vendor but they've been no help.
 
Can you show that user's [tt].profile[/tt] contents?


HTH,

p5wizard
 
Here's the .profile

pg /U/user/sccadm/.profile
#!/bin/ksh
trap "exit 1" QUIT INT TERM
# ------------------------------------------------------------------------------
# SCC profile for all logins (Author: Leszek L. 01.1994)
# @(#) $RCSfile: .profile,v $$Revision: 1.23 $$Date: 2005/12/30 15:38:58 $
# ------------------------------------------------------------------------------
# Logins structure.
# Environment variables are set using following hierarchy (assuming current
# directory is specific users's home directory : /etc/environment,
# /etc/profile, /.profile, ../.environment, ../enviro_generic, ./.environment.
# and .environment$MSITE -> for multisite environments only
# All variables used in ../.environment and ../.enviro_generic and
# ./.environment are exported automatically.
# File ../.custom is designated to add some additional shell
# commands valid for all logins. File ./.custom defines unique for specific
# login commands. Create ../.nologin file to disable all logins. Create
# ../.nologin.<logname> file to disable specific login. Contents of ../.nologin
# file will be displayed on users terminal when he attempts to login.
# Create .runonaux file to run login always on the backup system.
# Create .runonmain file to run login always on the main system.
# Create .runonthis file to run login always on the current system.
# ------------------------------------------------------------------------------
set -o nolog # protect against creating huge .sh_history
umask 006 # to allow edit $DICT files
set -a # export environment
HOSTNAME=$(hostname)
[[ -n $RUNHOSTNAME ]] && HOSTNAME=$RUNHOSTNAME
MSITE= # mutisite logins ( e.g a_lab )
# used in .enviro_generic
MSITE_= # used in $LABPARAM and below
[[ -z $HOMEDIR ]] && HOMEDIR=$HOME # to handle Run!
TMPS=${HOMEDIR##*/} && TMPMS=${TMPS%%_*} && [[ "$TMPMS" != "$TMPS" ]] && MSITE=$
TMPMS && MSITE_=${MSITE}_

TMPS=${HOMEDIR%%gui*} && [[ ${#TMPS} -ne ${#HOMEDIR} ]] && GUI=gui

# ------------------------------------------------------------------------------
# 1. Set proper environment
# 2. Load functions
# 3. Perform global custom scripts
# ------------------------------------------------------------------------------
[[ -f ../.auto.environment ]] && . ../.auto.environment # custom global en
vironment
[[ -f ../.environment ]] && . ../.environment # custom global environment
[[ -n ${MSITE_} ]] && [[ -f ../.${MSITE_}environment ]] && . ../.${MSITE_}enviro
nment
[[ -f ../.enviro_generic ]] && . ../.enviro_generic && . ../.environment
# generic global environment
[[ -n ${MSITE_} ]] && [[ -f ../.${MSITE_}environment ]] && . ../.${MSITE_}enviro
nment
# multisite environment
[[ -f ./.environment ]] && . ./.environment # local environment
[[ -f ./.enviro_generic ]] && . ./.enviro_generic && . ./.environment
# local environment
set +a # do not export
[[ -f ../.custom ]] && . ../.custom # global script
USERD=$UDIR/user # ksh functions
[[ -n $USERDIR ]] && USERD=$USERDIR/user # to have $HOMEDIR UDIR indepdent
export USERD
[[ -f $USERD/.functions ]] && . $USERD/.functions
UnsetLibPath && unset LIBPATH

if EnvOK && LoginOK
then
if ( MainSys && RunOnMain ) || ( AuxSys && RunOnAux ) || RunOnThis
then
[[ -f ./.custom ]] && . ./.custom # local script
else
. $UDIR/bin/auxprofile!
rlogin $(OtherHost) -l $LOGNAME
fi
fi
Exit # exit from current shell when regular login only
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top