php exec is not executing the command

0 votes

I have tried to use exec() with 'whoami' to check if it works and I got the result of

nt authority\system

Now I need to run a .exe file with parameters from PHP via the exec() function. 

When I run this command from the PHP file:

exec('..\..\some_file.exe folder="C:\path_to_folder" param=1.xml report=2.xml');

Even exec('notepad.exe'); is not working. Does something have to be done with PHP configurations maybe?

Jul 24, 2022 in PHP by Kithuzzz
• 38,000 points
1,506 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

I've already mentioned that I'm new to the exec() method. After conducting some additional research, I discovered that the command 2>&1 needs to have 2>&1 added to the end ().

I appreciate @mattosmat bringing it up in the comments as well. Because you indicated it was a Linux command and I am using Windows, I didn't immediately attempt this.

I've now learned that the command is truly being executed in the background. Because of this, I was unable to witness it actually running as I had anticipated.

My, advice is to use that command. It will point out all the errors and also tell you info/details about execution.

exec('some_command 2>&1', $output);
print_r($output);  // to see the response to your command

I hope this helps you.

answered Jul 25, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In PHP

0 votes
0 answers

PHP is not recognized as an internal or external command in command prompt

I am getting this error when I ...READ MORE

May 7, 2022 in PHP by narikkadan
• 63,600 points
2,275 views
0 votes
0 answers

Php artisan make:auth command is not defined

I ran this command in Laravel 5.2 but ...READ MORE

Jul 21, 2022 in PHP by narikkadan
• 63,600 points
1,609 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,415 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,634 views
0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,840 points
5,985 views
0 votes
1 answer

'composer' is not recognized as an internal or external command in windows server

For anyone coming here from Google who ...READ MORE

answered Feb 17, 2022 in Others by Aditya
• 7,680 points
21,501 views
0 votes
0 answers

Find PHP version on windows command line

I wanted to know the version of ...READ MORE

Jun 14, 2022 in PHP by narikkadan
• 63,600 points
1,012 views
0 votes
0 answers

Need XAMPP with PHP 5.4 version - windows

Can someone please share with me any ...READ MORE

Jun 21, 2022 in PHP by narikkadan
• 63,600 points
1,076 views
0 votes
0 answers

Create PDF file using PHP

I want to create a PDF file ...READ MORE

Jun 24, 2022 in PHP by narikkadan
• 63,600 points
489 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP