Results 1 to 5 of 5
Is there a way to capture all the stdout being generated? I am running a series of bash/perl scripts that all spawn off child processes, aside from piping every system ...
- 08-01-2007 #1Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
stdout
Is there a way to capture all the stdout being generated? I am running a series of bash/perl scripts that all spawn off child processes, aside from piping every system call to a log file, is there anyway to capture all the stdout all of these processes output?
Thanks
- 08-01-2007 #2Linux User
- Join Date
- Jul 2004
- Location
- Poland
- Posts
- 368
Hi, how about grouping them together in a subshell or a script and redirecting the entire the subshell/script??
Code:(echo Alice; echo has; echo a; echo cat) > /tmp/file.txt
"I don't know what I'm running from
And I don't know where I'm running to
There's something deep and strange inside of me I see"
- 08-01-2007 #3Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
I don't believe that will work, as the sub processes are all kicked off at different times during the script.Hi, how about grouping them together in a subshell or a script and redirecting the entire the subshell/script??
Code:(echo Alice; echo has; echo a; echo cat) > /tmp/file.txt
- 08-01-2007 #4
A process inherits its stdout from its parent. So if I redirect the stdout of the original script, all of its children will have their stdout redirected as well.
EDIT:
An example:
Note how even the child process prints to the redirected stdoutCode:alex@danu ~/test/c $ cat stdout_redirect.c #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main() { pid_t cid; cid = fork(); puts("Both processes should print this"); if(cid == 0) { puts("Only the child should print this"); return 0; } puts("Only the parent should print this"); return 0; } alex@danu ~/test/c $ gcc -Wall stdout_redirect.c alex@danu ~/test/c $ ./a.out > redirected_output alex@danu ~/test/c $ cat redirected_output Both processes should print this Only the child should print this Both processes should print this Only the parent should print thisDISTRO=Arch
Registered Linux User #388732
- 08-01-2007 #5Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
Thanks, I thought I had tried that, but apparently not..
That worked.


Reply With Quote