Jump to content

Recommended Posts

In the browser when I open the file I  need to see the output of the ifconfig linux command on the server.

 

This is the index.php

 

<?

$iplist = shell_exec("ifconfig");

print "<pre>$iplist</pre>";

?>

 

but when I open the index.php in a browser I can see only the first couple of lines, nothing more. Can someone help me what to do?

 

The strange thing is when I run the index.php from the command line with "php index.html" it shows the correct result.

 

Any help..?

 

Thanks,

 

Link to comment
https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/
Share on other sites

I just ran it locally, and due to the way it lists the interface type specifications, I had to add htmlentities() to get it to display properly. Try it this way:

 

<?php
$iplist = shell_exec("ifconfig");
print "<pre>" . htmlentities($iplist) . "</pre>";
?>

Still the same. It is not the problem how the output it is list, it is the problem that the list/output it is not complete. On other machine I have it works without a problem, but both machines have exactly same OS, apache and php version etc... Completely identical.

I get this:

 

<pre>eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00 

          inet addr:xxx.xxx.xxx.xxx  Bcast:xxx.xxx.xxx.xxx  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:392973281 errors:0 dropped:652694 overruns:0 frame:0

          TX packets:617472358 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:100

          RX bytes:123590836828 (115.1 GiB)  TX bytes:527309097095 (491.0 GiB)

          Memory:fb5e0000-fb600000

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:4553992 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4553992 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:1967405149 (1.8 GiB)  TX bytes:1967405149 (1.8 GiB)

 

</pre>

coincidence !!... I've been working in the same problem/behavior with a testing code for more than 1 hour and I've been having exactly the same issue... output from exec(), shell_exec(), passthru() are truncated.

 

Test machine is WXP with Apache/PHP/MYSQL ... weird..

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.