Knowledgebase

Portal Home > Knowledgebase > Articles Database > pphp beginner problem, how to exec linux command from php


pphp beginner problem, how to exec linux command from php




Posted by saskaf, 09-12-2010, 03:07 PM
Hello all. I'm beginner (started learning it 2-3 days ago) in PHP so here is my problem. I want to exec linux command with php script using argument which is posted to the php script from html. So here is the code: ========================================== index.html --------------------------------------------

Login:

            

=============================================== and here is the exec.php ------------------------------------------- =============================================== but nothing is printed on the next screen. can someone help me and tell me what i'm doing wrong?

Posted by saskaf, 09-12-2010, 03:08 PM
so what I can realize is the php can not execute "ip addr" or...???

Posted by Codebird, 09-12-2010, 03:45 PM
could be that exec is disabled on the server...

Posted by saskaf, 09-12-2010, 04:35 PM
It is a dedicated server, everything is by default, nothing is changed.

Posted by saskaf, 09-12-2010, 04:36 PM
How to check if it is disabled or not?

Posted by Codebird, 09-12-2010, 04:50 PM
phpinfo(), or check the php.ini try shell_exec at the place of exec maybe the output isn't coming because of exec

Posted by saskaf, 09-12-2010, 08:59 PM
Tried and still the same. What or where should I look in ini.php to see if exec is enabled or not?

Posted by whmcsguru, 09-12-2010, 11:13 PM
If you posted more about what you were trying to do, you'd get more help I'm sure. What,exactly is this form trying to do?

Posted by AirJordansHead, 09-12-2010, 11:24 PM
Hi, In my own experiences, "Cron Job" feature would be a nice choice inside your hosting control panel for this purpose. all the best,

Posted by whmcsguru, 09-12-2010, 11:27 PM
Cron has nothing to do with this post.

Posted by saskaf, 09-13-2010, 12:58 AM
Yes, cron has nothing to do with this. Also, this is just an exercise, no control panel, nothing.

Posted by saskaf, 09-14-2010, 08:52 AM
I just realize this. I have for testing this index.php file with contents in it: $iplist"; ?> which need to give me the output of the ifconfig in the browser. However on the browser when I open the file I can see only first 2 interfaces, but I have 8 interfaces. 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,

Posted by REMX, 09-14-2010, 09:13 PM
Try without the
 tag and see if it lists all of it. It works for me either way but I only have 6 interfaces though.
				

Posted by Doh004, 09-15-2010, 04:02 PM
That would be a spammer who just wants his signature to show up in more threads :p



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language:

Contact us