bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about redirecting output of spawned processes


From: Eric415
Subject: Question about redirecting output of spawned processes
Date: Thu, 12 Feb 2009 17:47:23 -0800 (PST)

Hello! I'm writing a bash script that will run a set of commands contained in
a file. I'd like each of these commands to redirect their output to a
separate file specified along with the command. For some reason, when I run
the master script using nohup (there is a reason for doing this, although
it's not apparent from the code below), each of the commands redirects their
output to nohup.out instead of the specified file. Any ideas? Thanks in
advance for your help.

Here is a snippet of the code:
=================================
...

# read in commands from file to array
commands=($(cat $commandsFileName))

## Main loop to run all commands
ran=0 # current command number
maxprocs=${#commands[*]} # number of commands
while [ $ran -lt $maxprocs ]; do
# Run another command in the background
${commands[ran]} &
((ran+=1)) # increment the command number
done
...
===========================



And the commands in the file look like this:
=======================
nohup nice prog1 &> prog1.out
nohup nice prog2 &> prog2.out
nohup nice prog3 &> prog3.out
...
=======================

Thanks in advance for any suggestions!
-- 
View this message in context: 
http://www.nabble.com/Question-about-redirecting-output-of-spawned-processes-tp21988680p21988680.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]