Re: basic bash help
From: David Fitzjarrell <oratune_at_yahoo.com>
Date: Fri, 27 May 2011 11:51:52 -0700 (PDT)
Message-ID: <384535.71229.qm_at_web65403.mail.ac4.yahoo.com>
Date: Fri, 27 May 2011 11:51:52 -0700 (PDT)
Message-ID: <384535.71229.qm_at_web65403.mail.ac4.yahoo.com>
Check the path for '.' as that allows running scripts/programs from the current directory, which is where you are when you run the script. If you remove that entry from the path then the 'proper' directory name should appear. David Fitzjarrell ________________________________ From: "Stephens, Chris" <Chris.Stephens_at_adm.com> To: "'oracle-l_at_freelists.org' (oracle-l_at_freelists.org)" <oracle-l_at_freelists.org> Sent: Fri, May 27, 2011 11:42:28 AM Subject: basic bash help I’m writing a script to allow the sysadmin’s to kill any active sessions for a particular database user. If the script is called as root, I re-invoke it as oracle. However, ‘dirname’ doesn’t seem to be working as expect and I have no idea why or how to get around it. A little bit of googl’ing didn’t help either so I turn to old faithful. J #!/bin/sh export ORAENV_ASK=NO export ORACLE_SID=xxxxxxx export SCRIPT=`basename $0` export SCRIPT_DIR=`dirname $0` echo "${SCRIPT_DIR} is the script dir." # Re-invoke this script as oracle if invoked as root CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1` if [ "$CUSER" = "root" ] then su - oracle -c "${SCRIPT_DIR}/${SCRIPT}" exit $? fi <rest of script> The script output is: “. is the script dir.” The script is located in /home/oracle/scripts/sql/topsecret Anybody know what the deal is? I’m guessing it has something to do with sub-shells or something but I don’t know how to work around it. I guess I can always hardcode the path but I would prefer not to. Thanks for any help! chris CONFIDENTIALITY NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by email reply.
-- http://www.freelists.org/webpage/oracle-lReceived on Fri May 27 2011 - 13:51:52 CDT