Unable to get an output from a piece of code snippet. :Confusing

Discussion in 'Perl Misc' started by maheshpop1@gmail.com, Nov 2, 2006.

  1. Guest

    Hi folks,

    I have this following code snippet, where I am looking to get some
    output from the CVS repository by running cvs log command at the bash
    shell. The puzzling thing is that when I put this code snippet in a
    seperate file called test.pl and run it. It runs fine and I can see the
    output of cvs log. But when I run this as part of a complete program,
    it fails at the @data = `$cmd 2>&-`; area.
    I am trying to print the @data and all I get is this output

    ----LOG OUTPUT ----
    cvsroot = /Repository/trunk cvsbase = /testCVS/junit g_isCli =
    printing in Proble.pl program argv : -log
    global command is LOG command = cvs log
    Command is cvs log
    11

    (The above 11 is the output of the @data that I get from the shell
    back).
    Here is the code snippet

    chdir('/testCVS/junit') or die "can't change dir" ;
    my $cmd = 'cvs log';
    print "Command is $cmd";
    @data = `$cmd 2>&- `;
    print LOG @data;


    any help is appreciated.

    regards,
    Mahesh
    , Nov 2, 2006
    #1
    1. Advertising

  2. On 11/02/2006 04:36 AM, wrote:
    > Hi folks,
    >
    > I have this following code snippet, where I am looking to get some
    > output from the CVS repository by running cvs log command at the bash
    > shell. The puzzling thing is that when I put this code snippet in a
    > seperate file called test.pl and run it. It runs fine and I can see the
    > output of cvs log. But when I run this as part of a complete program,
    > it fails at the @data = `$cmd 2>&-`; area.
    > I am trying to print the @data and all I get is this output
    >
    > ----LOG OUTPUT ----
    > cvsroot = /Repository/trunk cvsbase = /testCVS/junit g_isCli =
    > printing in Proble.pl program argv : -log
    > global command is LOG command = cvs log
    > Command is cvs log
    > 11
    >
    > (The above 11 is the output of the @data that I get from the shell
    > back).
    > Here is the code snippet
    >
    > chdir('/testCVS/junit') or die "can't change dir" ;
    > my $cmd = 'cvs log';
    > print "Command is $cmd";
    > @data = `$cmd 2>&- `;
    > print LOG @data;
    >
    >
    > any help is appreciated.
    >
    > regards,
    > Mahesh
    >


    "&-" is not valid for bash as far as I can tell. Most people do "2>&1"
    to redirect standard error to standard output.


    --
    Mumia W. (reading news), Nov 2, 2006
    #2
    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. SM
    Replies:
    0
    Views:
    374
  2. scigeek
    Replies:
    7
    Views:
    367
    scigeek
    Sep 8, 2009
  3. Patrick Plattes

    Download a file piece by piece

    Patrick Plattes, Nov 30, 2006, in forum: Ruby
    Replies:
    2
    Views:
    203
    Patrick Plattes
    Nov 30, 2006
  4. Maruthi Reddy

    Get the piece of code in perl

    Maruthi Reddy, Jun 14, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    103
    Tad McClellan
    Jun 17, 2007
  5. Replies:
    5
    Views:
    97
    apatheticagnostic
    May 8, 2008
Loading...

Share This Page