Operating System - HP-UX
1834660 Members
2591 Online
110069 Solutions
New Discussion

at command in rc script with parms

 
Scott Lindstrom_2
Regular Advisor

at command in rc script with parms

I want to have one of my rc scripts use the "at now + 5 minutes" syntax, but the problem I have is the file to be executed has a parm:

case $1 in

'start')
su - appuser -c "/bin/at -f /usr/bin/application start now + 5 minutes"


This command fails with the message "bad time specification" I think because it believes the word 'start' should be the time specification. (If I take 'start' out the syntax is OK but obviously this is not what I want).

I can make this work if I make an entirely new script that just does the "/usr/bin/application start" but I an trying to avoid that.

I have tried a hereis document but could not get that to work in a rc script.

Any ideas on how to make this work?

Scott
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: at command in rc script with parms

Hi Scott:

> I can make this work if I make an entirely new script that just does the "/usr/bin/application start" but I an trying to avoid that.

Why? Afterall, a wrapper script is often used to supply default arguments. It's a minor bit of indirection for infrequent use here.

Regards!

...JRF...
Peter Nikitka
Honored Contributor

Re: at command in rc script with parms

Hi,

you can create the temporary script on the fly, including a self-cleanup, if '/usr/bin/application' has execute rights:

case $1 in

'start')
echo "/usr/bin/application start
ret=\$?
rm -f /tmp/start_app$$
exit \$ret" >/tmp/start_app$$
su - appuser -c "/bin/at -f /tmp/start_app$$ now + 5 minutes"


mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Dennis Handly
Acclaimed Contributor

Re: at command in rc script with parms

Obviously the correct way to handle it is to encode the parm in the script, and exec the real one. Or what Peter suggests.

Another way is to symlink multiple scripts to one and look at $0 to determine if this is "start" or what.
Scott Lindstrom_2
Regular Advisor

Re: at command in rc script with parms

Thanks everyone for their replies; I went with using a second script.

Scott