【发布时间】:2016-06-06 10:46:46
【问题描述】:
当我使用终端/Bash 调用 Image Magick 命令(例如“convert”)时,我的命令成功了。如果我使用 C# 脚本中的系统进程使用相同的命令“convert”将参数传递给 Bash 控制台,它将返回一个未通过 StandardRedirectError 找到的错误命令。
为什么使用系统进程时找不到命令?例如
ProcessStartInfo startInfo = new ProcessStartInfo("/bin/bash");
startInfo.WorkingDirectory = installFolder;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
if (process != null) {
process.StandardInput.WriteLine ("convert"); //error: command not found
process.StandardInput.WriteLine ("echo \"hello world\""); //output: "hello world"
谢谢
【问题讨论】: