Visit The New, Modern Unix Linux Community


Capture output of command triggered in background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture output of command triggered in background
# 1  
Capture output of command triggered in background

Is there any way to trigger a sequence of commands in parallel and capture their output in variables? e.g. something on the following lines

Code:
x=`echo "X" &`
y=`echo "Y" &`
z=`echo "Z" &`

so that $x, $y, and $z evaluate to X, Y and Z res.
# 2  
unsure?

Why evaluate in parallel? Sequential evaluation will result in the variables being set as you state. Perhaps you are trying to do something different?
# 3  
Yes you could use process substitution with exec:
Code:
exec 4< <(sleep 4s; echo A)
read -u 4 __
echo "$__"
exec 4<&-

If you're going to execute an external binary use exec:
Code:
exec 4< <(exec yes)

# 4  
I am not really running echo statements Smilie that was just an example. The actual statements are function calls to SQL procedures which can take 10-15 minutes to complete. I want to trigger these in parallel to speed up execution of my job.
# 5  
Although a little convoluted you couid save each, (set of?), result(s) to disk and then read the contents of each saved file at your leisure...

Just an alternative thought...
# 6  
Quote:
Originally Posted by jawsnnn
I am not really running echo statements Smilie that was just an example. The actual statements are function calls to SQL procedures which can take 10-15 minutes to complete. I want to trigger these in parallel to speed up execution of my job.
Yes my example was just an example as well. You could use your sql commands there. If you intend to send input instead you could make use of input process substitution instead (>()).
# 7  
I'd guess that due to resource competition the resulting overall time will not be much faster than the serial execution.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #115
Difficulty: Easy
Linux is a continuation of the Unix design philosophy.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

Python Paramiko multi threading to capture all output for command applied in loop

My issue : I am getting only last command output data in ouput file. Though comamnd "print(output)" displays data for all 3rd column values but the data saved in file is not what required it hs to be the same which is being printed by command"print(output)". Could you please help me to fix this,... (0 Replies)
Discussion started by: as7951
0 Replies

2. HP-UX

How capture all user command line output?

Hi I want to know how capture all user command line output and save this commands and outputs to text files? if you have script for this subject please give me.:o please help me thank you (6 Replies)
Discussion started by: amvhd
6 Replies

3. Shell Programming and Scripting

Expect command when triggered by launchd

Hi folks, Im having trouble with an expect command in a shell script I use to back up mac os x servers. This one is being run on a 10.8.2 Server as part of a larger bash script. The script executes perfectly all the way through when triggered on the command line, but when launchd triggers it at... (4 Replies)
Discussion started by: rowie718
4 Replies

4. Solaris

How to capture Output of truus command

Hi I want to check if some process is sleeping. I can see that in truss -p <pid> I want to capture output and check that output if proces sis sleeping. Please suggest way to capture output of truss command or other way to check if process is sleeping (1 Reply)
Discussion started by: ankush_mehra
1 Replies

5. Shell Programming and Scripting

Log Capture for Background Process

Hi , I am running a backgorund process called hello.sh ./hello & Now i need to capture the log file as it produces the output . i am not able to use " >> " nor " tee " to capture the output file / log file . Please let me know how can i do it ? Regards, Deepak Konnur (3 Replies)
Discussion started by: dskonnur
3 Replies

6. Shell Programming and Scripting

Enter the command to capture output--help

&& echo "PLEASE enter the command to capture output" || echo "Processing your command manual" x=$# echo $x while do while man $@ | read -r line do >$@.txt ... (1 Reply)
Discussion started by: rrd1986
1 Replies

7. Solaris

How to capture only some part of output when command executed??

Hi, When I execute this command prtdiag -v output sample : System clock frequency: 160 MHZ Memory size: 4GB ==================================== CPUs ==================================== E$ CPU CPU CPU Freq Size ... (4 Replies)
Discussion started by: vijaysachin
4 Replies

8. Shell Programming and Scripting

How do I capture multiple lines of the status output of a command?

I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command: sh-3.2$ ftp -u ftp://username:password@computerdomain/directory/ file_to_be_uploaded Note: My environment allows me to issue... (2 Replies)
Discussion started by: zzz1528
2 Replies

9. Shell Programming and Scripting

[csh] How to capture output from a command and pass it on to a variable?

Hi there! I'm trying to write a script that will capture output from a command and assign it to a variable. Let's say, for example, I'd like to catch from inside the script whatever the following command outputs: ls *.aaa and put it into a variable "listoffiles". What I tried was: set... (3 Replies)
Discussion started by: machinogodzilla
3 Replies

10. Solaris

how to capture oracle export log while running as background process

I ran the Oracle 9i export command from a terminal to export out a big table using "exp andrew/password file=andrew.dmp log=andrew.log" From the terminal I can see that the export is running as there is some output from the oracle export job. The export job is not complete yet. When i go check... (4 Replies)
Discussion started by: hippo2020
4 Replies

Featured Tech Videos