- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Executing commands with parameters in variables
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 09:34 PM
тАО03-27-2007 09:34 PM
The script is used in a cluster when cron is executing a command, to determine whether the cluster package is present (or has failed over to another node), before actually executing the desired command.
The shell script itself takes arguments to determine whether it has to change user, source the users profile etc. before executing the command, and it logs the output from the command to a file, giving the logfile the same name as the actual command or Oracle SQL script with the extention .log
When all the check etc. is processed, the command is executed using 2 variables
$COMMAND $RUNCOMMAND
where the content of the variable
$COMMAND may be /bin/su - USER -c
$RUNCOMMAND is for example who -r
The echoed variables, just before execution, contains all desired commands and options, but the command which is executed after changing user, is only the command without options (in this case it only executes the who command, but is missing the -r option)
I have tried a lot of different ways of quoting (both with and without escaping quotes with backslash). I also tried using eval and exec, but this doesn't help.
How can I make sure that the command is executed with the options contained in the $RUNCOMMAND variable?
Henrik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 09:49 PM
тАО03-27-2007 09:49 PM
Re: Executing commands with parameters in variables
$ $COMMAND "$RUNCOMMAND"
>The echoed variables, just before execution, contains all desired commands and options
You need to write yourself a printenv script that prints all of argv. You'll see in your case you had two parms, who and -r.
After sh's -c, that -r may be a sh option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 09:53 PM
тАО03-27-2007 09:53 PM
Re: Executing commands with parameters in variables
try runing in sh -x mode or with set -x
Environment problem likely.
Please post output:
echo the variables just prior to execution.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 09:57 PM
тАО03-27-2007 09:57 PM
Re: Executing commands with parameters in variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2007 11:34 PM
тАО03-27-2007 11:34 PM
Re: Executing commands with parameters in variables
Steven for the input.
Dennis, I already tried a variaty of quoting
${COMMAND} ${RUNCOMMAND}
${COMMAND} "${RUNCOMMAND}"
${COMMAND} \"${RUNCOMMAND}\"
But it seems that using the version you wrote (without array though):
$COMMAND "${RUNCOMMAND}"
and executing the script using quotation on of the who -r command in the commandline, did the trick:
/usr/contrib/bin/cmcpp.sh -P SERVER -p -u USER -c "who -r"
Thanks.