OfficeLinebacker has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, esteemed monks!

UPDATE: Less Code!

Here's the code:

#!/opt/local/bin/perl -w use IPC::Run; use strict; $workdir="/fma/prod1/isa/logs"; $logfile="$workdir/test.log"; open(LOG,">$logfile") || die "Error: Could not open $logfile: $!\n"; print "*-*-begin_run-*-*\n"; chdir("$dir"); @cmd=$ARGV[0]; { run (\@cmd, '>pty>', sub{ print "$_[0]";}, '2>', sub { chomp $_[0]; +print "<b>$_[0]</b>\n";}) or die("Error executing child. Child return +ed $&\n"); } print "*-*-end_run-*-*\n"; close(LOG);
, which works reasonably well. However, if, in the run() command, I turn the '2>' into '2>pty>', I get nothing to STDERR. How can I make the program think both are attached via different ttys? Or, will that even make a difference?

_________________________________________________________________________________
Without me, it's just aweso

  • Comment on How to use pty for both STDERR AND STDOUT in IPC::Run, while doing something different with each?
  • Download Code

Replies are listed 'Best First'.
Re: How to use pty for both STDERR AND STDOUT in IPC::Run, while doing something different with each?
by samtregar (Abbot) on May 22, 2006 at 19:06 UTC
    I'm sorry, there's no way I can read that code. Do you have something against white-space? Perhaps you could give perltidy a try? And while you're at it, how about a "use strict"?

    -sam

      I compressed the part where I set up and open the log file so as so reduce screen RE; shall I add some blank lines or remove the context?

      As far as using strict; will that help my particular problem?

      _________________________________________________________________________________
      Without me, it's just aweso

        Yes, you should make code you post here maximally readable and as short as possible. I bet lots of people that could have helped you skipped right past your post when they saw that god-awful block of code.

        I don't know if "use strict" will solve your problem, but it certainly can't hurt!

        -sam

      better?

      _________________________________________________________________________________
      Without me, it's just aweso

        Moderately. That run() line is still nuts and you've got a lot of lines with far too few spaces in the top chunk. But's definitely a lot more readable now.

        -sam