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

M

maheshpop1

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
 
M

Mumia W. (reading news)

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top