Perl/apache if we run the Perl script on apache for display the result of Linux command it is not able to execute the Linux command and not display it into the browser.

eg. We want to display the result of "ping" command but not able to identify what is the problem on my apache it doesn't display the result but in command line it displays the result.

Recommended Answers

All 2 Replies

Does the apache user have the right to execute the command? You should post the code. You probably want to redirect stdout to a variable too and then print the variable.

On windows/apache this works fine as a cgi program:

#!c:/perl/bin/perl.exe
print "Content-type: text/html\n\n";

print "Ping:<br><pre>";

system("ping www.yahoo.com");

print "</pre>";

output:

Ping:

Pinging any-fp.wa1.b.yahoo.com [209.191.122.70] with 32 bytes of data:
Reply from 209.191.122.70: bytes=32 time=62ms TTL=38
Reply from 209.191.122.70: bytes=32 time=61ms TTL=38
Reply from 209.191.122.70: bytes=32 time=61ms TTL=38
Reply from 209.191.122.70: bytes=32 time=61ms TTL=38

Ping statistics for 209.191.122.70:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:
Minimum = 61ms, Maximum = 62ms, Average = 61ms
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.