Jump to content


Need help with exec()

  • Please log in to reply
3 replies to this topic

#1 JustFoo

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 19 July 2006 - 02:37 PM


Im trying to run a program from php using exec function but the only thing im getting returned is Array() and -1
The program just checks the file type of the file and prints out in the command line what it is and i need that information

$test = exec("start /B c:\Program"." Files\GnuWin32\bin\file.exe C:\PHP\php.exe", $output, $return);
echo "<br />".$return."<br />";
echo $test."<br />";

thanks for any help

#2 Ninjakreborn

  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 02:41 PM

exec() and system() are dangerous when running through user input, make sure you never give the end users the ability to run anything through exec or system without severe cutting down, and checking there text, also I don't know how to help on this specifically but some advice.


Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.

#3 tomfmason

  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 19 July 2006 - 02:50 PM

I am also some what new to this function. But here is a script that I use to reload ISC Bind. It returns the message "Sever restarted successfuly"

Maybe this will work for what you want.


$handle = popen( 'C:\windows\system32\dns\bin\rndc.exe reload', 'r');
echo fread( $handle, 4096 );
pclose( $handle );


Business man is right that it is dangerous to allow users to run anything through exec or system.

Good luck

P.S. when ever you get it working, please post the fix

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux

#4 JustFoo

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 19 July 2006 - 03:08 PM

I gave popen a try and still no dice any other ideas it seems the exe is not running or im just not getting back the output but im guessing more towards the exe not running at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users