backtick not printing the 'echo'ed line

D

dn_perl

I want to print a line using shell script via perl.

Contents of the file 'myshell' are :
-------------
#!/bin/csh
echo "line from shell script" ;
-------------

Contents of the file 'myperl' are :
-------------
#!/bin/perl
use strict ;
`myshell` ;
-------------

If I run 'myperl' it prints nothing on my monitor.
But if I replace backticks with 'system' call, the line in the shell
script is printed.

New contents of 'myperl' are :
-------------
#!/bin/perl
use strict ;
system ("myshell") ;
-------------

Why doesn't the 'echo' statement in the shell-script print on the
monitor when backticks are used?

TIA.
 
B

Ben Morrow

Quoth (e-mail address removed) ([email protected]):
I want to print a line using shell script via perl.

Contents of the file 'myshell' are :
-------------
#!/bin/csh
echo "line from shell script" ;
-------------

Contents of the file 'myperl' are :
-------------
#!/bin/perl
use strict ;
`myshell` ;
-------------

If I run 'myperl' it prints nothing on my monitor.
But if I replace backticks with 'system' call, the line in the shell
script is printed.

New contents of 'myperl' are :

This is the converse of the FAQ 'Why can't I get the output of a command with
system()?'.

Ben
 
B

Brian McCauley

Ben Morrow said:
Quoth (e-mail address removed) ([email protected]):
`myshell` ;

[...] it prints nothing on my monitor.

This is the converse of the FAQ 'Why can't I get the output of a command with
system()?'.

Yes, and it is also a FAQ in its own right: 'What's wrong with using
backticks in a void context?'

Those that will not learn from the FAQ are condemned to repeat it.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 

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
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top