abacus2015 Posted December 30, 2014 Share Posted December 30, 2014 Hi I have a problem in running an external executable .exe or .bat. For example using the following php code: $abc= system("C:\test\test.bat 2>&1"); printf ("TEST1:"); printf ($abc); $abc= system("whoami 2>&1"); printf ("TEST2:"); printf ($abc); I get the following result: Access is denied. TEST1:Access is denied.servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default) Obviously the file test.bat exists in the directory C:\test\. And I am running this on a windows 2008 server with access from the web. Any help would be appreciated, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/ Share on other sites More sharing options...
requinix Posted December 30, 2014 Share Posted December 30, 2014 That iwam_plesk user needs execute permissions for test.bat, and probably on anything it may try to execute too. Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501189 Share on other sites More sharing options...
abacus2015 Posted December 30, 2014 Author Share Posted December 30, 2014 Actually the iwam_plesk user has full permissions. The cacls command show this: Any other ideas? cacls test.bat C:\test\test.bat servername\IWAM_plesk(default):(ID)F Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501192 Share on other sites More sharing options...
requinix Posted December 30, 2014 Share Posted December 30, 2014 Side comment: The path isn't actually C:\test\test.bat, right? You've made sure that you're escaping your backslashes in the path? Because strictly speaking your code is trying to execute C:estest.bat 2>&1. system() goes through cmd.exe. Does the user have execute permissions on that too? And you've verified that it has permissions on whatever test.bat is trying to run? Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501196 Share on other sites More sharing options...
abacus2015 Posted January 1, 2015 Author Share Posted January 1, 2015 Hi there and happy new year! The specific user has execution rights for cmd.exe. In addition I am escaping the backslashes in the path, this does not seem to be the issue. For example if I place the file in the current directory (to avoid the backslashes): $abc=system("test.bat 2>&1"); printf ("TEST1:"); printf ($abc); $abc=system("whoami 2>&1"); printf ("TEST2:"); printf ($abc); assuming that test.bat is just the following: echo "Hello WOrld!" print "Hello WOrld!!!!" I get the following response TEST1:servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default) i.e. the test.bat seems to be ignored and does not return anything whereas if I change the code to this (testttt.bat is missing from the current folder): $abc=system("testttt.bat 2>&1"); printf ("TEST1:"); printf ($abc); $abc=system("whoami 2>&1"); printf ("TEST2:"); printf ($abc); I get 'testtttt.bat' is not recognized as an internal or external command, operable program or batch file. TEST1:operable program or batch file.servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default) I think it is a permissions issue, but I cannot locate the root of the problem. Any advice would be highly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501410 Share on other sites More sharing options...
requinix Posted January 1, 2015 Share Posted January 1, 2015 system() only returns to you the last line of output. Maybe that line is empty? Try exec and its second argument. Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501430 Share on other sites More sharing options...
abacus2015 Posted January 1, 2015 Author Share Posted January 1, 2015 Using $abc=exec("test.bat 2>&1", $abc_output); printf ("TEST1:"); print_r ($abc_output); $abc=system("whoami 2>&1"); printf ("TEST2:"); printf ($abc); gives TEST1:Array ( ) servername\iwam_plesk(default) TEST2:servername\iwam_plesk(default) so it still seems to return nothing!! this is so strange! Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501435 Share on other sites More sharing options...
abacus2015 Posted January 2, 2015 Author Share Posted January 2, 2015 just upgraded to PLESK 12 from PLESK 10 and it seems to solve the problem. Obviously this was a bug of PLESK v.10. Quote Link to comment https://forums.phpfreaks.com/topic/293514-access-denied-problems-with-external-executable/#findComment-1501487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.