parallel processing via system() command and logging output

  • Thread starter ClanCampbellChandler
  • Start date
C

ClanCampbellChandler

Trying to do parallel clearcase operations over many VOBs in
parallel...code snippet:

foreach $vob (@VLIST) {

chdir($vob);
system("cleartool find -all -version 'lbtype($OLDIB)
&& !lbtype($NEWIB)' -exec \"cleartool mklabel -replace $NEWIB \\
\"%CLEARCASE_XPN%\\\"\" &");
}

This seems to work just fine as is, but I would prefer to log the
output rather than seeing stdout. The current implementation allows
all the spawned processes to return stdout to screen in a mumbled
order. I would simply like the individual processes to get logged to
unique logfiles....perhaps /tmp/$vob.txt.

Ideas?

Thanks,

CCC
 
J

Jürgen Exner

ClanCampbellChandler said:
I would prefer to log the
output rather than seeing stdout. The current implementation allows
all the spawned processes to return stdout to screen in a mumbled
order. I would simply like the individual processes to get logged to
unique logfiles....perhaps /tmp/$vob.txt.

Ideas?

Yep. reading the manual for the functions you are using would help. See
'perldoc -f system', third paragraph, fourth sentence:

This is
*not* what you want to use to capture the output from a
command,
for that you should use merely backticks or "qx//", as
described
in the section on "`STRING`" in the perlop manpage.


Or just redirect the output into a file using the means provided by your
command shell.

jue
 
A

Andrew DeFaria

ClanCampbellChandler said:
Trying to do parallel clearcase operations over many VOBs in
parallel...code snippet:

foreach $vob (@VLIST) {

chdir($vob);
system("cleartool find -all -version 'lbtype($OLDIB)
&& !lbtype($NEWIB)' -exec \"cleartool mklabel -replace $NEWIB \\
\"%CLEARCASE_XPN%\\\"\" &");
}

This seems to work just fine as is, but I would prefer to log the
output rather than seeing stdout. The current implementation allows
all the spawned processes to return stdout to screen in a mumbled
order. I would simply like the individual processes to get logged to
unique logfiles....perhaps /tmp/$vob.txt.

Ideas?
Yeah just add "> /tmp/$vob.txt" to the end of the command. Or better yet
"> /tmp/$vob.txt 2>&1" to make sure stderr goes there too.

As an aside, you do realize that %CLEARCASE_XPN% is a Windows'ism don't
you. Assuming you are on Windows then how does "/tmp" apply? You should
write your code so that it works on both Windows and Unix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top