NEED HELP ON EXEC function
Posted: Thu Aug 07, 2008 11:50 pm
Hello,
I am trying to execute a .exe program through PHP. The basic function i am trying to use is exec.
The program needs the path of a particular directory as its arguement. But the path has spaces and this is not getting recognised by the command.
Here is the code..
//Code for executing the ReportSender
$target_path = "\"E:/Naresh/C++ projects/Report Requests\"";
$exelocation = "\"E:/Naresh/C++ Projects/ReportSender/ReportSender/bin/Release/ReportSender.exe\"";
echo "COMMAND IS $cmd \n";
$cmd = $exelocation." ".$target_path;
exec($cmd,$return_val);
print_r($return_val);
//Code ended..
The output is
//output for the program
COMMAND IS "E:/Naresh/C++ projects/ReportSender/ReportSender/bin/Release/ReportS
ender.exe" "E:/Naresh/C++ projects/Report Requests"
Array
(
)
//out put ended..
Now i have copied and pasted the same command and i was successful in executing through commandline.
Since there are spaces in the command given, i have included double quotes (") to include them.
I have also tried placing escape characters for space instead of putting whole things in quotes.. still no use..
Can anyone help me with this??
I am trying to execute a .exe program through PHP. The basic function i am trying to use is exec.
The program needs the path of a particular directory as its arguement. But the path has spaces and this is not getting recognised by the command.
Here is the code..
//Code for executing the ReportSender
$target_path = "\"E:/Naresh/C++ projects/Report Requests\"";
$exelocation = "\"E:/Naresh/C++ Projects/ReportSender/ReportSender/bin/Release/ReportSender.exe\"";
echo "COMMAND IS $cmd \n";
$cmd = $exelocation." ".$target_path;
exec($cmd,$return_val);
print_r($return_val);
//Code ended..
The output is
//output for the program
COMMAND IS "E:/Naresh/C++ projects/ReportSender/ReportSender/bin/Release/ReportS
ender.exe" "E:/Naresh/C++ projects/Report Requests"
Array
(
)
//out put ended..
Now i have copied and pasted the same command and i was successful in executing through commandline.
Since there are spaces in the command given, i have included double quotes (") to include them.
I have also tried placing escape characters for space instead of putting whole things in quotes.. still no use..
Can anyone help me with this??