0

I want to run command via php, what I've tried

<?php
$out=exec("pwd")
echo $out
?>

Output: c//xampp/htdocscommands

Problem arised in this case

<?php
putenv('PATH=C:\xampp\htdocs\command\execute ');
$out=exec('pwd');
echo $out;
?>

Output: operable program or batch file.

Then I try to run even simple command exe("pwd"), I'm getting this error

operable program or batch file.

What I'm trying exactly is

  1. I need to run command via php exec or other syntex too
  2. I need to set the path right way

e.g.: exec("cd path some_command")

QuantStats
  • 1,448
  • 1
  • 6
  • 14
Balaji
  • 9,657
  • 5
  • 47
  • 47
  • The `pwd` is a program inside your `C:\xampp\htdocs\command\execute` directory or is the Linux pwd command? And Whey you put the directory in env? – Ali Khalili Nov 16 '19 at 09:57
  • i accidently used because of i am tryng to change my path upto cmd directory folder after i used putenv stopped all command also like ipconfig too so why i post this – Balaji Nov 16 '19 at 10:25
  • 1
    https://stackoverflow.com/questions/1679045/php-exec-command-how-to-specify-working-directory Does this answer help you? – Ali Khalili Nov 16 '19 at 10:34
  • Now directory working but i still get same above mentioned error – Balaji Nov 16 '19 at 10:46

0 Answers0