简体   繁体   English

用PHP来执行命令行

[英]Using Php to execute command line

I got some problem while using php to execute command line. 使用php执行命令行时遇到一些问题。

I have a software and I need to execute the software to export pdf by using cmd command line. 我有一个软件,我需要用cmd命令行来执行软件导出PDF。

(The software need to be executed by using command-line) (该软件需要使用命令行执行)

Therefore i wrote a php code. 因此我写了一个PHP代码。

<?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. 我已经试过字符串 'C:\\ XmlServer.exe C:\\ input.xml中' 正在CMD。

But I can't using php to execute command line to get the same result. 但我不能用PHP来执行命令行来获得相同的结果。

I also tried exec($cmd); 我也尝试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. 我想像运行命令行一样运行php。

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. 但是在php中使用相同的代码无效。

-- Update - 更新

using echo shell_exec($cmd); 使用echo shell_exec($cmd); is okay, but no output. 是好的,但没有输出。

try with echo like that : 尝试像这样的回声:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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