blagojkk Posted September 14, 2010 Share Posted September 14, 2010 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 More sharing options...
Pikachu2000 Posted September 14, 2010 Share Posted September 14, 2010 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1110983 Share on other sites More sharing options...
blagojkk Posted September 14, 2010 Author Share Posted September 14, 2010 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. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1110996 Share on other sites More sharing options...
Pikachu2000 Posted September 14, 2010 Share Posted September 14, 2010 Load it in the browser and do a "View Source" to see if something in the output is causing the browser to cut off the output to the screen. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111000 Share on other sites More sharing options...
blagojkk Posted September 14, 2010 Author Share Posted September 14, 2010 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> Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111003 Share on other sites More sharing options...
blagojkk Posted September 14, 2010 Author Share Posted September 14, 2010 I think it is a problem with php itself. I have 3 servers, on 1 of them it is working without a problem, on other 2 don't, but I can not figure out what is the difference because they are completely identical. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111006 Share on other sites More sharing options...
Pikachu2000 Posted September 14, 2010 Share Posted September 14, 2010 So that output is different than what you get if you issue ifconfig at a command line? That's weird. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111010 Share on other sites More sharing options...
mikosiko Posted September 14, 2010 Share Posted September 14, 2010 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.. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111018 Share on other sites More sharing options...
blagojkk Posted September 14, 2010 Author Share Posted September 14, 2010 Problem solved. It was apache server side permission problem. Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111121 Share on other sites More sharing options...
mikosiko Posted September 14, 2010 Share Posted September 14, 2010 could you share the solution in your case? Link to comment https://forums.phpfreaks.com/topic/213391-shell_exec-do-not-list-whole-output/#findComment-1111126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.