Catch the process id number in unix

With my java program I run command in Unix. This application I start in background (nohup start.sh &). How can I catch the process ID number of my application? I use next string for code:
String command[] = {"/bin/sh", "-c", "/bin/" + command, "/bin/searcId"};
In run this line whit Runtime.exec()
command is "nohup start.sh &" and the searchId is a Unix script for catching process ID number (this script works fine, when I run it in Unix).
What can be wrong???
MArko

I arrived at this thread doing a Google search on how to obtain the process id of an executable launched from Java. The following code is not recommeded for released code, but it was helpful for my debugging purposes.
try
    Process proc = Runtime.getRuntime().exec("executable");
    Field pidField = proc.getClass().getDeclaredField("pid");
    //pid field in UNIXProcess class is private - make it accessible
    pidField.setAccessible(true);
    System.out.println("Exec'ed process ID is: " + pidField.get(proc));
catch (Exception e)
    e.printStackTrace();
}The process id field for the UNIXProcess is "pid." On Windows, I believe it is "handle."

Similar Messages

  • Catch the process terminate from the task manager

    Is there a way to catch the event of terminating the application from the the
    processes tab in task manager?
    I have created desktop app, and if a user termintates the app in the task
    manager, I'd like to be notified. I tried windowclosing in windowlistner, but nothing seems to be
    working for an improper shutdown of application.
    Thanks in advance

    Have you tried adding a shutdown hook? There alot of subtleties to a shutdown hook. You can read the documentation for
    Runtime.addShutdownHook(Thread hook)

  • How to get the Process order Number (Deatials by providing Salese order)

    Hi
    I want help to get the Process order details against with sales order number
    in which table i ll get this information and any particular  Function module is available???
    Regards
    Jagadish

    here KDAUF is empty
    Any other table is there i checked AUFK also AFKO also i ma not getting.

  • Catch the inbound delivery number when VL31n is saved.

    Hello Friends,
    In order to get inbound delivery when VL31N is saved, i am using the BADI :
    DELIVERY_PUBLISH ...this is having 2 methods.
    1.PUBLISH_BEFORE_COMMIT ( having import parameter it_changed_data...this structure is having inbound delivery number)
    2.PUBLISH_AFTER_SAVE (no parameters)
    when i am saving ....i am able to get into <b>publish_after_save</b> ...how to get
    that number into PUBLISH_AFTER_SAVE ?
    With Ever Smile & Regards,
    Madhu!!

    I dont know about said BADI but i think you can use LE_SHP_DELIVERY_PROC which has documentation in EN also and there are several methods which can be used for delivery process.

  • Process Order number as batch number for produced materiai

    Hi gurus
    Is it possible in SAP to automatically set the process order number as the batch number for an semi finished good or finished good? Is there a config like that in SAP?
    Thanks

    Hi,
    Refer this [link|http://help.sap.com/saphelp_46b/helpdata/fr/e9/c6f9bdaa28d3119b440060b0671acc/content.htm]
    you have to use EXIT_SAPLV01Z_001 and EXIT_SAPLV01Z_002 in the case were you want to Copying the production order number to the batch number.
    Regards,
    Dhaval

  • Process Order Number

    Hello Friends,
    I have an issue which is when we create a process order and when we save it the process order number is not coming in continuous series and it is coming in randam numbers. Can any one give me solution for this issue.
    Thanks,
    KS

    Hi Niraj,
    Thanks for your response as per your suggestion i have checked the number range for Process Order and it is Internal only not external. Would you please hlep me out to close this issue
    Thanks,
    KS

  • HT201304 Visa has changed for the purchase of Apple products, i did not know how I put the new MasterCard number to finish the process of buying products Thank you

    Visa has changed for the purchase of Apple products, i did not know how I put the new MasterCard number to finish the process of buying products Thank you
    i have ibad mini
    and iphone4
    laptop sony
    can you sent for me the anser

    Changing Account Information  >  http://support.apple.com/kb/HT1918

  • How to catch the error occurred in Integration Process, and then save it?

    1. how to catch the error occurred in Integration Process, and then save the detailed error message to the file?
    2. there are fault message type for inbound message interface, how to use the fault message type in IR?
    Thanks,
    Michael
    Message was edited by: Spring Tang
    inital
    Message was edited by: Spring Tang
    detailed message output
    Message was edited by: Spring Tang
    fault message type

    Hi Spring,
    If u give an exception step along with your Transformation Step, whenever some error occurs in your message mapping, this exception block wil be triggered.
    You can configure your exception block to do all exception processing that you want. This exception handling is like any other java Exceptio n Handler. You can do anything that you want in your exception handler block on the basis of your requirements.
    <i>If an exception is triggered at runtime, the system first searches for the relevant exception handler in surrounding blocks. If it does not find the correct exception handler, it continues the search in the next block in the block hierarchy.
    When the system finds the correct system handler, it stops all active steps in the block in which the exception handler is defined and then continues processing in the exception handler branch. Once the exception handler has finished processing, the process is continued after the block.
    If the system fails to find an exception handler, it terminates the integration process with an error.</i>
    Regards,
    Bhavesh

  • HT1349 I scratched my Itunes card and i scrached off the serial number in the process. How can i recover it.

    I scratched my itunes card an i scratched off the serial number in  the process. How can i recover it.

    If you cannot track it via iCloud, then you unforunately out of luck and will have to hope for the best.  You can try and retrace your steps as well.  There is no way to track it.
    B-rock

  • Several process listening to the same port number

    I hope I am in the right form (it's the third one I am trying).
    I have server/client application, one server that handles a lot of clients. In general when ever a client approach the server, the server create new process (fork()) that handle the client request.
    I would like to know if there is a problem that several processes (parent and several child processes) are listening to the same port number, is it better to create thread that would handle the client request, instead of creating a child process?
    To better understand the problem I create very simple client and server application.
    This is a part of the server application:
    The server creates a socket, bind to this socket and then listen to this socket.
    After that in a while (1) loop he waits for accept:
    int sockclient = accept(sockId,(struct sockaddr*)(&client_addr), &addrLen);
    When the server get a sockclient (client ask for service) he create new process (fork()) that handle the client request.
    struct sockaddr_in addr, client_addr;
    bzero(&addr,sizeof(struct sockaddr_in));
    addr.sin_family = PF_INET;
    addr.sin_port = 8865;
    bcopy(ent->h_addr_list[0],&(addr.sin_addr), ent->h_length);
    // bind
    bind(sockId,(struct sockaddr*)(&addr), sizeof( struct sockaddr_in));
    If it would help I can add the all code.
    If you knows about articles that talked about this subject It might help too (I am talking about advantages and disadvantages of thread against process but regardless of sockets).

    You might look at this article
    http://httpd.apache.org/docs-2.1/misc/perf-tuning.html
    under the section "accept Serialization - multiple sockets".

  • Confirmation number sequence in the process order

    Hi,
    When we create a process order , system assigns the confirmation no for each of the operation & these confirmation numbers are in sequence.
    In our case we have activity numbers in the recipe as 0010, 0020, 0030, 0040, 0050, 0060...... Subsequently we have inserted operations..now the sequence has become 0010, 0020, 0030, 0040, 0041, 0042, 0050, 0060...... Now when we create the process order, the confirmation numbers for operations 0041, 0042 comes after 0060. We have a development which has a pre-requisite that the sequence of confirmation no's should be as per sequence of operations.
    Any idea how to achieve the correct sequence of confirmation no's?
    regards,
    Mohit

    Dear Mohit,
    I have find the route cause BUT I Don't know how to fix it
    Based on Operation ID, system is creating a confirmation No
    Since you have created a operation 41 and 42,  System gives the operation ID next to 60
    Thats the reason system is giving the confirmation No after 60
    I don't know how To add operation ID in routing

  • Move-item: The process cannot access the file because it is being used by another process.

    Hey,
    I have a powershell script where I first use Get-childitem to receive a number of files.
    Then I do some stuff with it and try to move the file afterwards.
    Unfortunately if I am using a lot of files I receive very often the error:
    The process cannot access the file because it is being used by another process.
    Even -Force parameter does not help further.
    Based on my look around it is not used by another process.
    I think it is still 'in use' by powershell from script commands previously.
    Is there any way to 'see' if the file is still in use currently and wait for this to end?
    Or can I 'close' the current usage of the file?
    Thank you :)

    Hey,
    Thank you.
    I build the following function.
    But either the $return = $true I receive "The process cannot access the file because it is being used by another process." when I try to move-item... :(
    Function Wait-FileUnlock($FilePath){
    Write-Host " "
    $FileInfo = New-Object System.IO.FileInfo $($FilePath)
    DO{
    try{
    $fileStream = $fileInfo.Open([System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read)
    $return = $true
    catch{
    Start-Sleep -Milliseconds 5
    Write-Host "." -NoNewline
    $return = $false
    While($return -ne $true)
    $Error
    return $return
    Another functions is:
    Function Wait-FileUnlock($FilePath){
    Write-Host " "
    DO{
    $Error.Clear()
    Rename-Item $FilePath $FilePath -ErrorAction SilentlyContinue | Out-Null
    Start-Sleep -Milliseconds 5
    Write-Host "." -NoNewline
    While($Error.Count -ne 0)
    This one waits .. but it seems not to end waiting at any time :(

  • I have just downloaded itunes 10.6 and  in the process my "podcast" option under library has disappeared! The files are still on my laptop. I can also see some of my recorded music in my itunes library but can play them - there is an exclamation mark next

    I have just downloaded itunes 10.6 and in the process my "podcast" option under library has disappeared! THe files are still on my laptop. I can also see some of my recorded music in the itunes library but can't play them - there is an exclamation mark next to each track. Basically I can't use itunes - is the only option remove and replace? Thanks in advance

    Visibility of the Podcasts section is controlled from within the Edit > Preferences dialog.
    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    Missing tracks
    Typically this can happen because a file or folder is accidentally shunted to the wrong location. iTunes can also get confused if it expects to be talking to an external drive which isn't there. If will often reset the default media folder location and may have trouble finding files in the old folders.
    Select one of your tracks that is missing in action. Press CTRL-I to Get Info. Cancel when asked to try to locate the file, then look at the location given on the summary tab. This where iTunes thinks the file ought to be? Now find out where it actually is. Post back the two locations for comparison. I should be able to give you some steps to reconnect everything once I can determine which of the things that might have gone wrong is most likely in your case.
    When you get it all working make a backup!
    tt2

  • Add button on seeded Advanced Table, to catch the person_id to generate xml report

    Hi All,
    We are having a requirement to generate pdf report from seeded page.
    And we kind a hit dead end. So was really looking for any inputs or insights.
    We personalized page to add a column with a button in it. We used javascript
    in destination URI to catch the event in PFR.
    javascript:submitForm('DefaultFormName',1,{'xxdbPrintPDF':'YES'});
    All is good until this point. But the EVEN_SOURCE_ROW_REFERENCE is showing as null, when we hit that
    personalized button on page. Where as it is giving right values if clicked on other seeded items in table.
    And each row has a distinct person_id. We need handle to person_id to generate that person specific report.
    Any thoughts would be greatly appreciated.
    Thanks
    Hari

    Forgot to mention earlier. Vacancy page has advanced table listing all the applicants applied.
    We need button across each applicant(i.e in each row). And when we hit that button, if we can get person_id.
    We can use that in whereclauseparams() to get specific rows for xml report.
    Tried to create button programmatically, and still not able to retrieve row number/person id
    PR code
        public void processRequest(OAPageContext oapagecontext,
                                   OAWebBean oawebbean) {
            super.processRequest(oapagecontext, oawebbean);
            OAAdvancedTableBean unUsedCCTxnsTable =
                (OAAdvancedTableBean)oawebbean.findIndexedChildRecursive("ApplicantQueryRegion");
            if (unUsedCCTxnsTable !=
                null) //If not able to find the table, skip the process
                //Create new column Category to the table
                OAColumnBean categoryCol =
                    (OAColumnBean)createWebBean(oapagecontext, COLUMN_BEAN, null,
                                                "XxcfiCategoryColumn1");
                OASortableHeaderBean column1Header =
                    (OASortableHeaderBean)createWebBean(oapagecontext,
                                                        SORTABLE_HEADER_BEAN, null,
                                                        "XxcfiCategoryColumn1Header1");
                column1Header.setText("Category");
                categoryCol.setColumnHeader(column1Header);
                // Create the actual leaf item under the first column
                OAMessageStyledTextBean leaf1 =
                    (OAMessageStyledTextBean)createWebBean(oapagecontext,
                                                           MESSAGE_STYLED_TEXT_BEAN,
                                                           null,
                                                           "XxcfiCategoryColumnLeaf1");
                leaf1.setViewAttributeName("AplPersonId");
                categoryCol.addIndexedChild(leaf1);
                unUsedCCTxnsTable.addIndexedChild(categoryCol);
                //add submitbutton
                 //Create new column Category to the table
                 OAColumnBean categoryCol1 =
                     (OAColumnBean)createWebBean(oapagecontext, COLUMN_BEAN, null,
                                                 "XxcfiCategoryColumn2");
                 OASortableHeaderBean column1Header1 =
                     (OASortableHeaderBean)createWebBean(oapagecontext,
                                                         SORTABLE_HEADER_BEAN, null,
                                                         "XxcfiCategoryColumn1Header2");
                 column1Header.setText("PDF");
                 categoryCol.setColumnHeader(column1Header);
                OASubmitButtonBean submitButton =(OASubmitButtonBean)createWebBean(oapagecontext,
                OAWebBeanConstants.BUTTON_SUBMIT_BEAN, null, "submitButton");
                submitButton.setViewAttributeName("AplPersonId");
                unUsedCCTxnsTable.addIndexedChild(submitButton );
    PFR code
        public void processFormRequest(OAPageContext pageContext,
                                       OAWebBean webBean) {
            OAApplicationModule appModule =
                pageContext.getApplicationModule(webBean);
            OAViewObject vo =
                (OAViewObject)appModule.findViewObject("ApplicantListVO");
            oracle.jbo.domain.Number num = null;
            if (vo != null) {
                OARow row = (OARow)vo.getCurrentRow();
                if (row != null) {
                    num =
    (oracle.jbo.domain.Number)row.getAttribute("AplPersonId");
            throw new OAException("Button Clicked by HM " + num.toString() +
                                  "-----" +
                                  pageContext.getParameter("XxcfiCategoryColumnLeaf1") +
                                  "-----" +
                                  pageContext.getParameter("submitButton") +
                                  "-----" +
                                  (String)pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE),
                                  OAException.ERROR);
    Any ideas will be of great help
    Thanks

  • How to catch the error if an RFC fails due to short dump

    Hi All,
      I was calling the RFC Function module in parallel processing depends on the number of work processors available. I am getting the return message from the Function module using the perform statement
       PERFORMING task_return ON END OF TASK
    But I am not able to catch the errors if the RFC has been terminated due to the dump or manually killing the RFC while running.
    I need how to handle the RFC if the call has been terminated due to the dump or system failure. Does the RFC return the sy-subrc at this time or can we able to catch the error in any other way.
    Thanks & regards,
    Vijay

    Hello Vijay,
    If you're calling RFC from outside SAP using the OCX-SAPFunctions-Library, then you can catch the dump or any other exception occuring in your SAP-Function.
    Assuming that, objRFCFunc is the RFC-Function you can get the Excepetion-Code through objRFCFunc.Exception.
    It returns a String. If the error was a dump, the String is "SYSTEM_FAILURE". If it is a "regular" Exception you'll get the Exceptioncode. E.g. "NO_DATA_FOUND".
    If you need any sample code e.g. VBA-code for use in Office-Applications, let me know.
    regards
    Sven

Maybe you are looking for

  • How to display 0INSP_CHAR description in the report?

    Hi experts I want to display description of 0INSP_CHAR in the report.. 0INSP_CHAR has 3 compounding objects so its displaying it as Q/1356933/11/20 instead of 20. I want to remove compound characteristics from the report & also want to display descri

  • Installer package not working

    I've posted this on the iDVD forum but I've decided it is more likely a general OS technical issue. Hopefully someone here can help me. When I double click the iDVD '06 install package the installer launches with menus along the top and an icon in th

  • Which printer is recommended by real users to print on glossy photo paper?

    My MG8100 can't seem to grab the glossy photo paper when I am printing pictures. Very frustrating to spend so much on a machine that is for printing photos and the rollers are plastic and won't grab the glossy paper. Thanks for any suggestions.

  • Incorrect Default Gateway for Clients using a Concentrator

    Hey all, Hopfully an easy one - I'm trying to configure a VPN Concentrator for use with the old VPN Client for an IPSec CVPN. The clients connect fine, but they are getting the incorrect default gateway during the address assignment. My address pool

  • Import records

    hi sapgurus what are import records and how to create import records? plz... answer this.