develooper Front page | perl.beginners | Postings from January 2002

Re: why does open()ing happen only at the <FD> line ?

Thread Previous | Thread Next
From:
Michael Fowler
Date:
January 10, 2002 11:26
Subject:
Re: why does open()ing happen only at the <FD> line ?
Message ID:
20020110192607.GA13915@shoebox.net
On Thu, Jan 10, 2002 at 06:54:25PM +0000, Prahlad Vaidyanathan wrote:
> <code>
> open(FD,"sudo less /var/log/messages |") ;
> print "test\n" ;
> my $line = <FD> ;
> print "$line\n" ;
> print "test #2\n" ;
> </code>
> 
> $ ./test.pl
> Password:test
>     [waits for password here]
> Jan  6 06:51:13 marvin syslogd 1.4-0: restart.
> 
> test #2
> </output>
> 
> As you can see, it runs 'sudo' _after_ printing "test\n". ie. when it
> reads from the file.

Um, how do you figure?  The sudo program prints out the "Password:" prompt,
and from your output you can clearly see "test" is after "Password:".  So
sudo is being run before "test" is printed.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About