[Mono-dev] excute linux command under mono C#

nekresh nekresh at gmail.com
Wed May 18 06:59:25 EDT 2011


The command is executed with the same use running apache.
So if apache's user doesn't have the rights to access/read/write to the
files, then your command neither.

You can try to "su apache_user" and try this command.
It's the same problem as not being able to move the files directly with the
mono API.

On Wed, May 18, 2011 at 12:54 PM, harmeet.singh at onebcg.com <
harmeet.singh at onebcg.com> wrote:

>  Hi
>
> Finally it works. Thanks
>
> Still having one problem. It works for physical path. But when we are
> trying to copy files to folder (mounted with amazon S3) it gives error. Log
> file shows permission denied error.
>
> Copy works while executing command from command line but doesn't run when
> executing from application. May be Apache/Mono server running application
> doesn't have full permissions.
>
> Any Suggestion.
>
> Thanks again for your help.
>
>   Regards,
>
> Harmeet Singh
> Software Engineer .NET
> Ext: 3023
>
>  Phone AU: +61 2 9114 6001    |    IN: +91 172 424 8888    |    UK: +44
> 2070 99 88 50    |    US: +1 866 420 9555
>  FaxAU: +61 2 9114 6002    |    IN: +91 172 424 8889    |    UK: +44 2070
> 99 49 55    |    US: +1 480 304 3080
>  [image: ONE BCG] <http://www.onebcg.com>
> This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete the
> original. Any other use of the email by you is prohibited.
> Please consider the environment before printing this email
>
>
>
> On 5/18/2011 2:06 PM, nekresh wrote:
>
> Standard non-error exit code on linux is 0
> If you get something else then an error as occured.
>
>  Are you sure that both path exists ?
> Do you have read/write rights ?
>
>  On Wed, May 18, 2011 at 10:22 AM, harmeet.singh at onebcg.com <
> harmeet.singh at onebcg.com> wrote:
>
>>  Hi
>>
>> I tried the code. My code is
>>
>> protected void Button1_Click(object sender, EventArgs e)
>>     {
>>         Label1.Text=Execute("/bin/cp"," -rp
>> /usr/local/lib/xsp/test/2.0/projectname/invoices/
>> /usr/local/lib/xsp/test/2.0/projectname/testupload/").ToString();
>>
>>     }
>>     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;
>>
>>
>>
>>          Process proc = System.Diagnostics.Process.Start(oInfo);
>>         proc.WaitForExit();
>>          int exitCode = proc.ExitCode;
>>         proc.Close();
>>
>>         return exitCode;
>>     }
>>
>>
>>  Output returned is 1. But Files are not copied to destination folder. Any
>> suggestions.
>>
>>   Regards,
>>
>> Harmeet Singh
>> Software Engineer .NET
>> Ext: 3023
>>
>>  Phone AU: +61 2 9114 6001 <%2B61%202%209114%206001>    |    IN: +91 172
>> 424 8888 <%2B91%20172%20424%208888>    |    UK: +44 2070 99 88 50    |    US:
>> +1 866 420 9555 <%2B1%20866%20420%209555>
>>  FaxAU: +61 2 9114 6002    |    IN: +91 172 424 8889<%2B91%20172%20424%208889>    |    UK:
>> +44 2070 99 49 55    |    US: +1 480 304 3080 <%2B1%20480%20304%203080>
>>  [image: ONE BCG] <http://www.onebcg.com>
>> This message is for the designated recipient only and may contain
>> privileged, proprietary, or otherwise private information. If you have
>> received it in error, please notify the sender immediately and delete the
>> original. Any other use of the email by you is prohibited.
>> Please consider the environment before printing this email
>>
>>
>>
>> On 5/17/2011 4:04 PM, nekresh wrote:
>>
>>  On Tue, May 17, 2011 at 12:03 PM, harmeets <harmeet.singh at onebcg.com> <harmeet.singh at onebcg.com> wrote:
>>
>>  Hi what will be exe and args here?
>>
>>
>> With your command : /bin/cp -rp
>> /usr/local/lib/xsp/test/2.0/projectname/invoices/
>> /usr/local/lib/xsp/test/2.0/projectname/testupload/
>>
>> The exe part will be "/bin/cp"
>> and the args part will be "-rp
>> /usr/local/lib/xsp/test/2.0/projectname/invoices/
>> /usr/local/lib/xsp/test/2.0/
>> projectname/testupload/"
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.comhttp://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>
> _______________________________________________
> Mono-devel-list mailing listMono-devel-list at lists.ximian.comhttp://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110518/2a5b01cb/attachment.html 


More information about the Mono-devel-list mailing list