0

I am working on Windows server and able to run command from command prompt

c:> %convertxls% {some args....}   

But when I run same command from php script

*shell_exec(%convertxls% ..... 2>&1);*

it gives me error as

%convertxls% is not recognized as an internal or external command, operable program or batch file.

I think when I am running command from command prompt, it run for user which logged in. And when I run the php script it run for "www" user for which path is not set.

Can anybody tell me where I am doing mistake?

*Note: I haven't written complete command.

Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
Kammy
  • 409
  • 1
  • 7
  • 26

3 Answers3

1

Supply the full path to the executable.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

ignacio right,I wanted to add one more point that ignacio did not specify .

Check the parameter disable_functions in the php.ini .

maybe this function is not allowed.

Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
0

This sounds like the environment variable %convertxls% is not set.

You can use putenv() to set it; alternatively, as Ignacio already says, specify the full path.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Thanks I have set convertxls using putenv() and its working correctly. But when I am using full path its not working and gives error 'C:/Program' is not recognized as an internal or external command, operable program or batch file. Any ways My work is done thanks once again. – Kammy Jul 19 '10 at 09:36
  • @Kamlesh You need to set the path in quotes. `"C:\Program Files\..."` – Pekka Jul 19 '10 at 09:40
  • note you might want to use single quotes not double quotes as using doubles means the backslash will be used a delimiter and lead to confusing errors – nathan Jul 19 '10 at 10:08