Pipe not working with /usr/bin/grep. Why is that?
Notice...
print `/usr/bin/dig -x $ip | grep PTR`;
....works, but:
print `/usr/bin/dig -x $ip | /usr/bin/grep PTR`;
....does not.
Another alternative:
$results = join("", grep(/PTR/, `/usr/bin/dig -x $ip`));
/g
> -----Original Message-----
> From: Robert Thompson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 31, 2001 5:31 PM
> To: [EMAIL PROTECTED]
> Subject: Outputting shell command to a browser
>
>
> Hello,
>
> I am working on a script that uses the backticks to execute a
> shell command, and I want to output the results to a webpage. The
> problem I am having is that the command I am running seems to take
> too long and the cgi does not return anything for that variable. Is
> there a way to make the backtickes wait longer or is there a better
> way to do this? I have tried the system command, but with similar
> results of empty values.
>
> #!/usr/bin/perl
>
> @ips = ("198.182.196.56","216.239.39.100");
>
> print "Content-type: text/html\n\n";
> print "<html>\n<body>\n";
> print "<pre>\n";
>
> foreach $ip (@ips){
> $results = `/usr/bin/dig -x $ip | /usr/bin/grep PTR`;
> $test = `echo foo`;
>
> print "\n";
> print "result: \"$results\"\n";
> print "test: $test\n";
> print "\n";
>
> }
>
> print "</pre>\n";
> print "</body>\n</html>\n";
>
>
> Here is the output from running it from shell, the values are all correct:
>
> >./foo.pl
> Content-type: text/html
>
> <html>
> <body>
> <pre>
>
> result: "56.196.182.198.in-addr.arpa. 10h37m56s IN PTR www.linux.org.
> "
> test: foo
>
>
>
> result: "100.39.239.216.in-addr.arpa. 23h59m16s IN PTR www.google.com.
> "
> test: foo
>
>
> </pre>
> </body>
> </html>
>
>
> Here is the source code from the page that is generated, the values
> are blank:
>
> <html>
> <body>
> <pre>
>
> result: ""
> test: foo
>
>
>
> result: ""
> test: foo
>
>
> </pre>
> </body>
> </html>
>
>
>
> Thanks,
>
> =-= Robert Thompson
>
> PS, I have tried running the cgi again once the IP addresses are
> cached (so they go quicker), but it still does the same thing so
> "too slow" is probably not acurate.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]