Jump to content

Archived

This topic is now archived and is closed to further replies.

JustFoo

Need help with exec()

Recommended Posts

Hello,

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


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

thanks for any help

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

[code=php:0]<?php

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

?>[/code]

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

Good luck
Tom

[b]P.S.[/b] [i]when ever you get it working, please post the fix[/i]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.