mono Process.Start how to find bash?
In my webapp i do the below. I know its correct because i tried 1) dumping start_sz to a text file 2) su www-data 3) copy/paste the extract string and it worked.
var start_sz = string.Format(@"bash -c 'ln ""{2}/{0}"" ""{2}/{1}""'", fn, newfn, System.IO.Directory.GetCurrentDirectory());
Process.Start(start_sz);
I get the exception below so with reasoning above i believe its saying bash cannot be found.
Cannot find the specified file
at System.Diagnostics.Process.Start_shell (System.Dia开发者_开发知识库gnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0
at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in :0
at System.Diagnostics.Process.Start (System.String fileName) [0x00000] in :0
at MySite.QueueManager.MakeLink (System.String fn) [0x00000] in :0
at MySite.QueueManager.ImageQueue2 () [0x00000] in :0
at MySite.QueueManager.ImageQueue () [0x00000] in :0
So, how do i fix this? basically i need to create a hardlink (soft is ok too) at run time in my asp.net app.
I thought maybe i need the full bash path so i tried /bin/bash -c
however that didn't work either.
Why not call ln
directly? Without bash
?
Process.Start("ln", params);
Also you may need to specify the full path:
Process.Start("/bin/ln", params);
In fact, Process.Start("bash")
works for me, thus check $PATH
environment variable, etc.
No, you know it's correct when used from a shell. That shell will take the path into account, unlike Process.Start
.
Just specify the full path to bash, which is almost certainly /bin/bash
.
精彩评论