Is there away to run script in background within the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is there away to run script in background within the script
# 1  
Old 02-14-2007
Is there away to run script in background within the script

Hello all

i have csh script called test.csh , and i need to run it in the background

so i do : test.csh &

but i wander can i tell within the script source to run it in the background automatically , without giving the user to add the "&"

when executing in the shell ?
# 2  
Old 02-14-2007
I'm not sure about the script running itself in the background, I doubt you can do that. You could have your script run all it's commands in the background but that isn't the same as what you're asking.

The simple solution I'd do is just write a one-liner script that calls the real script in the background, then have your user run that. For your real script test.csh, have a script called starttest.sh that goes

#! /bin/sh
/path/to/test.csh &

And you're done.

By the way, not to start a religous war or anything but you are aware csh is very rarely used for scripting because of many flaws with it, right? I'd suggest scripting in sh since it is most portable, or if you need it ksh or bash. Csh is fine for interactive use as your shell if you like it best, but it isn't good for scripting.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to run a shell script in background without showing in the terminal?

Hi Guys, i am having a script which checks for ip address is pingable or not,when i execute this script in terminal it keeps on showing the pinging status of every ip address and it takes more time when i check for 100 ip address,How to do run a script in background without showing in the terminal... (4 Replies)
Discussion started by: Meeran Rizvi
4 Replies

2. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

3. Shell Programming and Scripting

Run command in background thru script

Dear All, Writing a script in which I want to run a command in background and keep it running even script is finished. I have tried like below, `truss -p <pid> >> & /tmp/log &` But doesnt work.. script goes running and nothing in log file. (7 Replies)
Discussion started by: Deei
7 Replies

4. Shell Programming and Scripting

Need to run the script in background, but having a problem

hi, we have a script which runs for the whole day and whenever the job fails, will send an alert to the mailbox. My problem here is that i need to give the jobname dynamically which is not possible if we run the script in background. Pls help me with this. Thanks Ajay (6 Replies)
Discussion started by: ajayakunuri
6 Replies

5. Shell Programming and Scripting

shell script does not work if run in background

Dear All, I am trying to run a script in background like ./scriptname.sh & but when i try to run it in background it is giving me an error "syntax error at line 12: `(' unexpected" at the line 12, there is a function definition "function getFileList()". This script runs fine if i run on... (2 Replies)
Discussion started by: bilalghazi
2 Replies

6. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

7. UNIX for Dummies Questions & Answers

Run script in the background with a time interval

I have a script I want to run in the background, and I have looked it up but I am not exactly sure how to do. First of all to run it in the background do you have to put something in the script or is it just a command when you go to run it. I found this solution to it but once again I am not to... (2 Replies)
Discussion started by: mauler123
2 Replies

8. Solaris

Best practice to run bash script in background

nohup /bin/bassh $HOME/scripts/test.sh > $HOME/log/test.log 2>&1 & nohup $HOME/scripts/test.sh > $HOME/log/test.log 2>&1 & Which is the good practice to run a script in background of above two ? does the first one will have any overhead on the system ? our system is SunOS 5.10... (2 Replies)
Discussion started by: mmasals
2 Replies

9. Shell Programming and Scripting

set schedule to run a script at background while logout

Hi, How can I run a script at 9:00am and 6:00pm everyday? Can I run it at background while I logout my account? Please help!! Many Thanks!! (1 Reply)
Discussion started by: happyv
1 Replies

10. Shell Programming and Scripting

how to run script at background

Hi all, I have a script like: echo Please input list file name: read listn for file in `cat $listn.txt` do send_file $file done normally, I will run the script like: :. resendfile Please input list filename: list1 #Then, the script will resend all file from the list1. However,... (4 Replies)
Discussion started by: happyv
4 Replies
Login or Register to Ask a Question