1
votes

Trying to execute aws cli commands with php shell_exec on local server (for tests). I'm using xampp, windows operating system, Laravel and php, I installed aws cli on windows.

Windows cmd recognizes the aws commands, but when I try to execute the aws command with shell_exec i get an error: "aws is not recognized as an internal or external command".

Tried this simple script:

$exec = shell_exec('aws --version');

$exec return null.

Appreciate any help.

2
It probably isn't found in the path. Try referencing aws via the full path. - John Rotenstein

2 Answers

1
votes

if you can't run the command directly in shell_exec(), then what you can do is make a batch file with the command and place it on the root of your website. Then, just run:

<?php echo exec("script.bat"); ?>

also, make sure to put any environment variables needed and recommend to use full path for the aws executable

0
votes

I solved it. It was pretty simple. It doesn't enough to restart xampp. I also had to quit xampp and re enter