Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Unable to get an output from a piece of code snippet. :Confusing

Reply
Thread Tools

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

 
 
maheshpop1@gmail.com
Guest
Posts: n/a
 
      11-02-2006
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

 
Reply With Quote
 
 
 
 
Mumia W. (reading news)
Guest
Posts: n/a
 
      11-02-2006
On 11/02/2006 04:36 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) 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.


--
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get this small piece of code to work? Need help SM XML 0 06-03-2008 12:45 PM
Get the piece of code in perl Maruthi Reddy Perl Misc 3 06-17-2007 03:03 PM
Interesting piece on spam to get you PHB to read... thingy NZ Computing 0 02-19-2007 07:11 PM
Download a file piece by piece Patrick Plattes Ruby 2 11-30-2006 07:48 PM
How to render a piece if ASP.NET code into HTML? Przemo ASP .Net 5 07-18-2004 05:12 PM



Advertisments