Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Using System Command in Perl

Expand Messages
  • Shlomi Fish
    ... In that case, make sure you use String-ShellQuote: http://search.cpan.org/dist/String-ShellQuote/ Alternatively use open -| , @list which is only
    Message 1 of 29 , Jun 25, 2009
    • 0 Attachment
      On Wednesday 24 June 2009 19:57:50 Jeff Soules wrote:
      > Maybe the backtick operator ` `? (Backtick on my keyboard is the
      > tilde key ~ without shift, but it might be different on your
      > keyboard).
      >
      > So in place of:
      > > system 'CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
      > > EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y';
      >
      > You'd do
      >
      > my $result = `CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
      > EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y`;
      >

      In that case, make sure you use String-ShellQuote:

      http://search.cpan.org/dist/String-ShellQuote/

      Alternatively use open '-|', @list which is only available on Windows.

      Regards,

      Shlomi Fish

      > and then look in $result for whatever the other utility would normally
      > print on the screen.
      >
      > $? is supposed to be set the same way for system() as for the backtick
      > operator, but maybe your other Windows program isn't returning a
      > status properly or something?
      >
      > On Tue, Jun 23, 2009 at 9:33 PM, Kevin Patterson<kpatters@...>
      wrote:
      > > Hi,
      > >
      > > I am writing a perl program to call/ execute another windows program
      > >
      > > Using the system command.
      > >
      > > I am trying to get/print the results to see if the command worked.
      > >
      > > Is there a way to capture the output of what the program ran??
      > >
      > > I tried using system ' ' and system(). I get the same results.. nothing..
      > >
      > > Here is my code so far.
      > >
      > > #!/usr/bin/perl
      > >
      > > # use strict;
      > >
      > > # use warnings;
      > >
      > > @client = qw(EM AS);
      > >
      > > #@client = qw(EM HR KR AS BF DB);
      > >
      > > my $eNV = "QW-D";
      > >
      > > my $T = '"';
      > >
      > > foreach $Client_Key (@client)
      > >
      > > {
      > >
      > > system 'CTMORDER -SCHEDTAB EM-$ENV-REPORT-LOGS -JOBNAME
      > > EM-$ENV-$Client_Key-AAL-EMAIL -ODATE ODAT -FORCE Y';
      > >
      > > print "Status: $? $!\n";
      > >
      > > }
      > >
      > > [Non-text portions of this message have been removed]

      --
      -----------------------------------------------------------------
      Shlomi Fish http://www.shlomifish.org/
      Freecell Solver - http://fc-solve.berlios.de/

      God gave us two eyes and ten fingers so we will type five times as much as we
      read.
    Your message has been successfully submitted and would be delivered to recipients shortly.