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!

method to force backgrounding a process without &

Status
Not open for further replies.
Jun 2, 2004
24
US
can I force a script to run in the background without having my users place an ampersand at the end of the command line? nohup?
 
Say the script is:
line1
line2
...
lineN
You can change it like this:
(
line1
line2
...
lineN
) &

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks, PHV!
It works in bourne, but not in my lengthy csh script, which yields this error on my Sun OS 5.6 machine:

Too many ('s

Is there an alternative for csh?
 
I am trying to avoid a wrapper, stefanwagner, but thanks nonetheless :)
 
Perhaps replacing the outer pair ( ) by { }

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
no go.
csh still complains about the lone braces (just like it did with the parens) even if not alone on a line of code.
I also tried brackets with the same poor result. darn csh shell :-|

I suppose a wrapper will do unless someone else has a handy tip. Thanks very much all!
 
Try putting the following at start of your script.
Well it is a sort of wrapper. It is just that the script is its own wrapper.

Code:
if ( $#argv > 0 && $argv[1] == "--in-background") then
    shift
else
    $0 --in-background $* &
    exit
endif

--------------------

Denis
 
What about...?
[tt]
echo script1.csh | batch[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top