Hi,
On Wed, 09 Jan 2002 Michael Fowler spewed into the ether:
[-- snip --]
> How did you go about determining this? As far as I know, this is not the
I'll explain. This is something I just ran.
[ My /var/log/messages is a test file containing 1 line only. ]
<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.
> perl -wle 'open(F, q{perl -wle "print STDERR q{test}" |") || die; sleep;'
>
> If the command was only executed when F is read from you'd never see "test".
> However, when I run the above, I see "test". The sleep is in there to prove
> it's not being run due to the implicit close at the end of the script.
Yes. I agree. But, I can't, for the life of me, figure out why my tests
with sudo work the way they do. Is it some system-specific quirk ?
> > ps. Is it inadvisable to open the said file like this (see the script
> > above) ? If so, why ?
>
> Opening it like this is fine, but I would use Perl to do the grepping, not
> several invocations of grep.
I changed that. But, I was wondering if there is a 'sudo' thingy for
perl ;-)
Thanks for the help, but I'm still puzzled.
pv.
--
Prahlad Vaidyanathan <[EMAIL PROTECTED]>
"May the forces of evil become confused on the way to your house."
-- George Carlin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]