简体   繁体   中英

Using Php to execute command line

I got some problem while using php to execute command line.

I have a software and I need to execute the software to export pdf by using cmd command line.

(The software need to be executed by using command-line)

Therefore i wrote a php code.

<?php 
$cmd ='C:\XmlServer.exe C:\input.xml';   
shell_exec($cmd);
?>

I've tried the string 'C:\\XmlServer.exe C:\\input.xml' is working on cmd.

But I can't using php to execute command line to get the same result.

I also tried exec($cmd); , but it still didn't work.

Could anyone help me solving the problem?

I want to run php just like running command line.

I wrote like the following in command line:

C:\> XmlServer.exe input.xml 

then it's ok to output a file for me. but using the same code in php didn't work.

-- Update

using echo shell_exec($cmd); is okay, but no output.

try with echo like that :

<?php  
  $cmd ='C:\XmlServer.exe input.xml';    
  echo exec($cmd);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM