Execute the cmd command with exec and return a blank result. I put the file named 2swf.exe in swftoolsto the website root directory and execute the command using the exec function in php.
$ Cmd = "c:/php/www/ipv2swf c:/php/www/upload/1.pdf c:/php/www/upload/1.swf"
Exec ($ cmd );
I directly paste this code into the command line and execute it correctly. the last two parameters that can be called by php but fail to be successfully exec are added. The second parameter is array (); the third parameter is 1, I directly put a php file under the same directory after modification. the exec (00002swf 1.pdf 1.swf) file can be successfully executed. why?
Note: The above code is completely passed in my local test. if it is put on the server, the above error occurs. all of them are apache locally used by IIS on windows2003.
Reply to discussion (solution)
First Read manual
Exec () The second parameter is the information returned by the screen. each behavior is a unit that forms an array.
First Read manual
Exec () The second parameter is the information returned by the screen. each behavior is a unit that forms an array.
Well, this array is empty, and there is no information on the uplink of the screen. it is correct to paste the command into the command line for direct execution.
Because you manually open the command line and undertake the system environment, you can directly run the file
However, using php for execution does not support the system environment. Therefore, you need to specify the executable file (such as exe)
This should be about user permissions.
You can directly place a php file in the same directory.
But it is obviously not running in web mode, because you cannot put the website root on the root of drive C.
Suggestion:
Move the website directory to drive D and grant anonymous users the execution permission
If you do not place your website on drive C, the system files may be accidentally damaged. at the same time, when the system crashes, the disaster recovery workload will be much smaller.
Because you manually open the command line and undertake the system environment, you can directly run the file
However, using php for execution does not support the system environment. Therefore, you need to specify the executable file (such as exe)
I added the cmd2swfcommand to .exe or couldn't execute it. I tried ipconfig. No problem. maybe it's still a path problem. I clearly wrote the absolute path. Is there a problem with the path?
$ Mcd = "D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ app \ %2swf.exe D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ mongod: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.swf"
Exec ($ cmd, $ out );
This is my cmd command. please give me some advice.
This should be about user permissions.
You can directly place a php file in the same directory.
But it is obviously not running in web mode, because you cannot put the website root on the root of drive C.
Suggestion:
Move the website directory to drive D and grant anonymous users the execution permission
If you do not place your website on drive C, the system files may be accidentally damaged. at the same time, when the system crashes, the disaster recovery workload will be much smaller.
Er, I put the moderator in the website root directory, not the C root directory.
D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package this is the root directory of my website
I put ipv2swf.exe under this directory, and then create an index. php in 1.pdf.
The code in it is exec (ipv2swf 1.pdf 1.swf)
This can be successful
Then the following code:
$ Mcd = "D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ app \ %2swf.exe D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ mongod: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.swf"
The path is too deep. there are spaces in the middle of the three parameters, but this will not work.
$ Mcd
$ Cmd
I see two different variable names.
$ Mcd
$ Cmd
I see two different variable names.
Well, this is what I just typed. sorry, I echo the cmd command in ie.
D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ app \ 4102swf.exe D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.pdf D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.swf
This is the path.
Try again with single quotes ...... I don't want this problem either. try it.
$ Cmd = "c:/php/www/ipv2swf c:/php/www/upload/1.pdf c:/php/www/upload/1.swf"
Exec ($ cmd );
This is the code in your post.
How can we get real results if you provide the information?
$ Cmd = "c:/php/www/ipv2swf c:/php/www/upload/1.pdf c:/php/www/upload/1.swf"
Exec ($ cmd );
This is the code in your post.
How can we get real results if you provide the information?
Sorry, I am sorry because my address is obtained in the program. I posted the program, so I did not directly write a url. I directly echo it. $ cms, this variable is the path.
D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ app \ 4102swf.exe D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.pdf D: \ JGY \ JGY_WEB \ JGY_PHP \ install_package \ uploadfile \ 2012 \ 1222 \ 20121222110539946.swf
I will analyze the problem of iis again? In the local apache test, it is normal for iis to check that all users have read and write permissions.
The first thing to solve is the permission issue.
If the command can be correctly executed in the command line or batch processing, the problem lies in "permission"
Of course, you will not disable the exec function.
I also encountered the same situation, but my command can be successfully executed, but there is no return value. I don't know where the problem is, and all permissions are available.