osl_executeProcess issue in Mac

Java, C++, C#, Delphi, ??? - Using the UNO bridges

osl_executeProcess issue in Mac

Postby Anandh » Mon Feb 11, 2013 1:52 pm

I have the following code in my MAC application to launch open office from my application,

Code: Select all   Expand viewCollapse view
{
......
OUString officePath = OUString::createFromAscii (" open -a /Applications/OpenOffice.org.app/Contents/MacOS/scalc");
rtl::OUString arg0 = rtl::OUString::createFromAscii("--autorun");
            rtl_uString* arguments[] = {
                arg0.pData
            };

oslProcessError osl_error = osl_executeProcess(officePath.pData,
                                                        arguments,
                                                        1,
                                                        osl_Process_DETACHED,
                                                        0,
                                                        NULL,
                                                        NULL,
                                                        0,
                                                        &rProcess );
 
        switch ( osl_error )
                {
                        case osl_Process_E_None:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NONE");
                            break;
                        case osl_Process_E_NotFound:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NotFound");
                            break;
                        case osl_Process_E_TimedOut:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_TimedOut");
                            break;
                        case osl_Process_E_NoPermission:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NoPermission");
                            break;
                        case osl_Process_E_Unknown:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_Unknown");
                            break;
                        case osl_Process_E_InvalidError:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_InvalidError");
                            break;
                        default:
                           printf("unmapped error!\n");
                 }

.....
.....
}

When executing above code, am getting oslProcessError osl_Process_E_Unknown. I don't have any clue what is wrong in the above code.Am using MAC OS 10.7.4. and am using OO 3.4.1
Openoffice version 3.4.1
Platform Mac/Windows
Anandh
 
Posts: 9
Joined: Fri Jan 18, 2013 3:21 pm

Launching OO from External Application using SDK method

Postby Anandh » Mon Feb 18, 2013 8:37 am

Hi there,

I have written the following code in my application to launch open office from my application,

Code: Select all   Expand viewCollapse view
........
        ........
        OUString appExe            = OUString::createFromAscii( "/Applications/Utilities/Terminal.app");
        OUString applicationExe = OUString::createFromAscii ("Terminal.app");
        OUString progArg1         = OUString::createFromAscii ("\"/Applications/OpenOffice.org.app/Contents/MacOS/soffice\"");
        OUString progArg2         = OUString::createFromAscii (" -invisible");
        OUString progArg3         = OUString::createFromAscii (" -accept=socket,host=localhost,port=8100;");
        OUString progArg4         = OUString::createFromAscii (" -accept=pipe,name=mypipe;");
        OUString progArg5         = OUString::createFromAscii ("urp;StarOffice.ServiceManager");

        OUString AppArgs = progArg1+progArg2+progArg3+progArg5;

        OUString FileURL;
        osl::FileBase::getFileURLFromSystemPath(appExe, FileURL);

        oslProcessError osl_error = osl_executeProcess(FileURL.pData, &AppArgs.pData,
                                                        1,
                                                        osl_Process_DETACHED,
                                                        0,
                                                        NULL,
                                                        NULL,
                                                        0,
                                                        &rProcess );
        printf("\n called execute process \n");
        switch ( osl_error )
         {
                        case osl_Process_E_None:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NONE");
                            break;
                        case osl_Process_E_NotFound:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NotFound");
                            break;
                        case osl_Process_E_TimedOut:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_TimedOut");
                            break;
                        case osl_Process_E_NoPermission:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_NoPermission");
                            break;
                        case osl_Process_E_Unknown:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_Unknown");
                            break;
                        case osl_Process_E_InvalidError:
                            osl_freeProcessHandle( rProcess );
                            printf("\n Execute process failed with E_InvalidError");
                            break;
                        default:
                           printf("unmapped error!\n");
            }


When executing above code, am getting oslProcessError osl_Process_E_Unknown. I don't have any clue what is wrong in the above code.Am using MAC OS 10.7.4. and am using OO 3.4.1. But when i run the below command in Terminal, it launches OO without any issue. What am doing wrong in calling osl_executeprocess method.

Code: Select all   Expand viewCollapse view
admin$ "/Applications/OpenOffice.org.app/Contents/MacOS/soffice" -accept=socket,host=localhost,port=8100; -accept=pipe,name=mypipe;urp;StarOffice.ServiceManager


Thanks in advance,
Anandh
Last edited by thomasjk on Mon Feb 18, 2013 9:25 pm, edited 1 time in total.
Reason: Moved post to add additional information to exsiting thread.
Openoffice version 3.4.1
Platform Mac/Windows
Anandh
 
Posts: 9
Joined: Fri Jan 18, 2013 3:21 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest