parallel processing via system() command and logging output

Discussion in 'Perl Misc' started by ClanCampbellChandler, Sep 25, 2008.

  1. 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
     
    ClanCampbellChandler, Sep 25, 2008
    #1
    1. Advertising

  2. ClanCampbellChandler <> wrote:
    [system()]
    >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
     
    Jürgen Exner, Sep 25, 2008
    #2
    1. Advertising

  3. ClanCampbellChandler wrote:
    > 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.
    --
    Andrew DeFaria <http://defaria.com>
    Indecision is the key to flexibility.
     
    Andrew DeFaria, Sep 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrei D.
    Replies:
    2
    Views:
    394
    Grant Edwards
    Aug 6, 2003
  2. Soren
    Replies:
    4
    Views:
    1,275
    c d saunter
    Feb 14, 2008
  3. Vivek Menon
    Replies:
    5
    Views:
    3,366
    Paul Uiterlinden
    Jun 8, 2011
  4. Vivek Menon
    Replies:
    0
    Views:
    1,774
    Vivek Menon
    Jun 10, 2011
  5. Replies:
    0
    Views:
    184
Loading...

Share This Page