单程过程。开始如何找到bash?
-
11-10-2019 - |
题
在我的WebApp中,我做以下。我知道它是正确的,因为我尝试了1)将start_sz倾倒到文本文件2)su www-data 3)复制/粘贴提取字符串并起作用。
var start_sz = string.Format(@"bash -c 'ln ""{2}/{0}"" ""{2}/{1}""'", fn, newfn, System.IO.Directory.GetCurrentDirectory());
Process.Start(start_sz);
我得到以下例外情况,因此上面的推理我认为找不到bash。
找不到指定的文件
在System.diagnostics.process.start_shell(System.Diagnostics.ProcessStartinfo startInfo,System.diagnostics.process.process Process)[0x00000] in:0
at System.diagnostics.process.start_common(System.Diagnostics.processstartinfo StartInfo,System.diagnostics.process.process Process)[0x00000] in:0
at System.diagnostics.process.start(System.Diagnostics.diagnostics.processstartinfo startInfo)[0x00000] in:0
at System.diagnostics.process.start(System.String FileName)[0x00000] in:0
在mysite.queuemanager.makelink(System.String FN)[0x00000] in:0
在mysite.queuemanager.imagequeue2()[0x00000] in:0
在mysite.queuemanager.imagequeue()[0x00000] in:0
那么,我该如何解决?基本上,我需要在我的ASP.NET应用程序中运行时间创建一个硬链接(也可以柔软)。
我以为也许我需要完整的bash路径,所以我尝试了 /bin/bash -c
但是那也不起作用。
解决方案
为什么不打电话 ln
直接地?没有 bash
?
Process.Start("ln", params);
另外,您可能需要指定完整的路径:
Process.Start("/bin/ln", params);
实际上, Process.Start("bash")
为我工作,因此检查 $PATH
环境变量等
其他提示
不,您知道使用时正确 从外壳. 。那个外壳会考虑到这条路,与 Process.Start
.
只需指定bash的完整路径,几乎可以肯定 /bin/bash
.