(???) Accessing the command line from inside a script (Yes, I'm a newbie) 
Author Message
 (???) Accessing the command line from inside a script (Yes, I'm a newbie)

Hi Folks,

        Sorry to bug you.  I know a lot of my questions must seem like
pretty simple stuff, but Ive only been studying Perl full-blast for 5
weeks now.

        Well, Ive got a question about opening pipes (correct term?) to
the command line, and, essentially, the Perl Script sits on hold while
a script is run from the command line, in the host computer.

        There was a command I saw that did this, but I cant fully
remember it or find it either on-line or in my reference books (Yes,
Ive been checking and checking....,) that went along the lines of:

(something) [| perl -e script_1.pl (options that go with it)];

        Does anybody know which command Im referring to?  

        Please help me out.  Im new to Perl, overwhelmed by the on-line
documentation that Im only slowly beginning to understand the
terminology of, (and theres _so much_ to wade through!), trying very
hard, have been putting a lot of time into figuring out how to make
this work and searching through on-line documentation, and look forward
to the day when I can help answer questions instead of just asking
them.

        I know the popular thing to do is to just tell someone to go look
at a web page, but thats not helping me out at all, and Ive looked
and looked and looked and....

Thanks!

Zyana



Tue, 05 Oct 1999 03:00:00 GMT  
 (???) Accessing the command line from inside a script (Yes, I'm a newbie)

Quote:

>    Well, Ive got a question about opening pipes (correct term?) to
>the command line, and, essentially, the Perl Script sits on hold while
>a script is run from the command line, in the host computer.
>    There was a command I saw that did this, but I cant fully
>remember it or find it either on-line or in my reference books (Yes,
>Ive been checking and checking....,) that went along the lines of:
>(something) [| perl -e script_1.pl (options that go with it)];
>    Does anybody know which command Im referring to?  

You may be referring to the feature that open(LS_OUTPUT, "ls |") will
run the command "ls" and return its results via the filehandle
LS_OUTPUT. If the second argument to open begins with or ends with a
vertical bar, the rest of the string is taken as the name of an
executable program, and that program is opened with either its
standard input or standard output redirected to the filehandle.

The strings passed to open don't need to be constants, they can come
from the command line. Often they do in the form of the magic "<>"
filehandle which automatically opens each element on the command line
in turn.

So,

  perl -ne print 'ls|'

will show the output of 'ls' and

perl -pe 'tr/a-mn-zA-MN-Z/n-za-mN-ZA-M/' \
    'lynx -dump http://random.yahoo.com/bin/ryl|'

will rot13 a random web page.
--
Andrew Langmead



Thu, 07 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. command line commands from inside perl ?

2. Newbie needs help- trying to submit command-line function to perl script via web

3. RE : DIFFICULT: Can't execute system command from FVWM, but can from the command line

4. Access to data generated inside bind's subroutine

5. Running a UNIX command from inside a perl script

6. Using passwd command inside a perl script

7. IIS: Perl CGI's execing command line progs, can't read from pipe

8. '--' on command line

9. 'do' and command-line parameters

10. access to unparse command line

11. How to access entire command line?

12. Getting access to command line parameters

 

 
Powered by phpBB® Forum Software