[Mono-dev] excute linux command under mono C#
harmeets
harmeet.singh at onebcg.com
Tue May 17 06:03:33 EDT 2011
Hi what will be exe and args here?
Duane Wandless wrote:
>
> Here is a class that I use to execute linux commands:
>
> internal int Execute(string exe, string args)
> {
> ProcessStartInfo oInfo = new ProcessStartInfo(exe, args);
> oInfo.UseShellExecute = false;
> oInfo.CreateNoWindow = true;
>
> oInfo.RedirectStandardOutput = true;
> oInfo.RedirectStandardError = true;
>
> StreamReader srOutput = null;
> StreamReader srError = null;
>
> Process proc = System.Diagnostics.Process.Start(oInfo);
> proc.WaitForExit();
> srOutput = proc.StandardOutput;
> StandardOutput = srOutput.ReadToEnd();
> srError = proc.StandardError;
> StandardError = srError.ReadToEnd();
> int exitCode = proc.ExitCode;
> proc.Close();
>
> return exitCode;
> }
>
> internal string StandardOutput
> {
> get;
> private set;
> }
> internal string StandardError
> {
> get;
> private set;
> }
> }
>
>
> On Mon, May 16, 2011 at 8:05 AM, harmeets <harmeet.singh at onebcg.com>
> wrote:
>
>> I tried this solution for executing linux command from
>> asp.netapplication.
>> It is not working for me. We just want to move files from one folder to
>> another. My code is
>> string cmd = "/bin/cp -rp
>> /usr/local/lib/xsp/test/2.0/projectname/invoices/
>> /usr/local/lib/xsp/test/2.0/projectname/testupload/";
>> System.Diagnostics.Process proc = new System.Diagnostics.Process();
>> proc.StartInfo.FileName = "bash"; //here
>> proc.StartInfo.Arguments ="-c ' " + cmd + " ' "; ////??????
>> proc.StartInfo.UseShellExecute = false; ///????
>>
>>
>> We cannot use File.Copy because destination folder is mounted with Amazon
>> S3. While copying files it shows error folder not found. We will have to
>> copy files using command line.
>>
>> --
>> View this message in context:
>> http://mono.1490590.n4.nabble.com/excute-linux-command-under-mono-C-tp1533563p3526039.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
--
View this message in context: http://mono.1490590.n4.nabble.com/excute-linux-command-under-mono-C-tp1533563p3528686.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list