Wrong output by pgrep -f command

Hello!
I have created a monitor, that check the running instances of a process under Linux (SLES11SP3) with SCOM 2012 SP1 CU4.
As monitor type I chose the "Microsoft.Unix.ShellCommand.TwoState.MonitorType" (which I have used successfully many times) and as shellcommand to get an output of the process count I used the shell command:
pgrep -l cron | grep -vc grep (in this example "cron"; the process name is irrelevant to our problem)
In the ssh session on the linux machine this command works fine and shows an output of "1", as exactly one cron is running. The SCOM Agent on the other hand shows an output (StdOut) of "2" on the same system (I have double checked
this with the winrm command to execute shellcommands from xml, too).
After some thinking I noticed that the "|grep -vc grep" part was not necessary (because pgrep does not list the "grep" process) and switched it with "| wc -l". Unfortunately the SCOM Agent and the winrm command for shellcommands
still showed a "StdOut" of "2" although only "1" cron was running on the system.
Now comes the interesting part:
Instead of "pgrep -f" I chose "pgrep -l" and finally the "StdOut" in SCOM matched the one on the system. So after another round of testing I found out that only "pgrep -f" seem to deliver a wrong "StdOut".
I can post proof for that, unfortunately Im on a tight schedule today, so if needed I can provide it on monday.
Maybe one of you has an idea, why scom always adds "1" when using "pgrep -f"?

If I understand correctly, you are comparing two situations:
1)  You manually run 'pgrep' in at a shell command prompt after using ssh to login to the Linux server
2)  The OpsMgr agent runs 'pgrep' as part of a monitor
And you are getting different results from the two cases.
In case #2, doesn't the command line you are giving to OpsMgr actually starts with /bin/sh -c, so that you can specify a command line that contains pipes, etc. which are executed by /bin/sh?  If so, then the OpsMgr agent is spawning a /bin/sh
process that has the pgrep command line as an argument, including the process name that pgrep is looking for.  /bin/sh is then in turn spawning the pgrep process.  The "extra" process that pgrep is finding is the /bin/sh process that is spawned by
the OpsMgr agent.  You won't have that process in case #1 when you are just running pgrep manually at a shell prompt.
Michael Kelley, Lead Program Manager, Open Source Technology Center

Similar Messages

  • Redirecting output after a "cat" command

    I first encountered this with "do shell script" in AS, and the issue also occurs in Terminal.
    Basically, I want to get contents from a file, make some changes via "sed ," and return the changed version to the same file -- but the file always winds up empty. Without the redirect, the commands work as expected.
    For example, in Terminal:
    cat --path to some file-- | sed 's/this/that/g'
    results in the expected changes (returned to Terminal)
    but
    cat --path to some file-- | sed 's/this/that/g' > path to some (same) file
    results in a blank file
    (The "sed" command isn't even necessary for this to happen; just trying to return the output of the "cat" command to the file results in a blank file.)
    I've certainly been able to accomplish this sort of thing with commands other than "cat." Is this something that's not possible with "cat" or do I have the syntax wrong?
    (Of course, I can get around this by following up with an "echo" command but, in "do shell script," that requires more code.)
    Thanks in advance for your comments.

    HI osimp,
       I've always thought that the "sed 's/this/that/g' < input > output" syntax looked cool because you can sort of see the flow of information. However, the end of the command is simply a pair of redirect directives. The first tells the shell to open the file and pipe the contents into the standard input stream of sed. Then the output of sed is piped into the output file.
       The command I was proposing, "sed 's/this/that/g' input > output", is simpler in that it tells sed to read the file directly rather than asking the shell to read it.
       You said above that you were interested in storing the result in a variable. That could be done simply with a command like:
    OUTPUT=$( sed 's/this/that/g' input )
    For many types of content this would work nicely but the shell will try to expand the output so plenty of things can cause errors. I was going to wait to post the above until I discovered a way around that expansion but I haven't had enough time to do that so I'm posting it and I'll see if I can improve it later.
       I know some about AppleScript and have written several scripts that combine capabilities of the shell with those of AppleScript. There are probably more people here that know AppleScript here than there are shell scripters on the AppleScript Discussion. You should try posting the whole question over here as well as over there. However, try and see if you can get the help of Deivy over there. He knows a lot about interactions between AppleScript and the shell.
    Gary
    ~~~~
       A memorandum is written not to inform the reader,
       but to protect the writer.
             -- Dean Acheson

  • Capturing the output of a os command line

    I need to capture the output of a os command line executed from one java program and I don't know how can do it.
    For example:
    Runtime.getRuntime().exec("hostid");

    Your suggestion worked very well, just in case that this could interest somebody, this is the complete solution
    Thanks for your help
    import java.io.*;
    public class HostID
    public static void main(String args[]){
    try{
    InputStream in = (Runtime.getRuntime().exec("hostid")).getInputStream();
    byte[] arreglo= new byte[200];
    int cantidad = in.read(arreglo);
    System.out.println(new String(arreglo,0,cantidad));
    } catch (IOException ioe){System.out.println(ioe.getMessage());}
    }

  • Report is giving wrong output while running in Background ?

    Hi,
    We have a report program which gives the correct output while running it in forground(or manually) but when we run it in backgroud it gives the wrong output. (The printout goes to the wrong printer.)
    I've read in a SAP doc that:
    NEW-PAGE PRINT ON  even gives unpredictable
    results when the print parameters are incomplete; and it suggested to use FM 'GET_PRINT_PARAMETERS to validate the print parameters before NEW-PAGE PRINT ON event . I tried the same but still our report is sending the printout to the wrong printer while running it in background.
    Other events used in the program are AT NEW and AT LAST .
    Can anyone confirm me NEW-PAGE PRINT ON, AT NEW and AT LAST  events work correctly in background mode also.
    Thanks,
    Bhavana

    hi
    good
    NEW-PAGE PRINT ON should be work in the background also,check your syntax with the below syntax,if still it is going to the different printer in the background than check with the configuration setting of printer for the particular report that you r printing,sometime it happens that even in the foreground the correct printer ideanfies but in the background that same printer didnt identify.
    NEW-PAGE PRINT ON
        NEW-SECTION
        PARAMETERS pripar
        ARCHIVE PARAMETERS arcpar
        NO DIALOG.
      DO 440 TIMES.
        WRITE (3) sy-index.
      ENDDO.
      NEW-PAGE PRINT OFF.
    ENDFORM.
    thanks
    mrutyun^

  • Concurrent generating wrong output format with TEXT as output type

    Hi,
    I have create a custom rdf and set TEXT as its output type.
    I want the text output to be specific format but the concurrent is not generating the exact expected output.
    Expected Output:
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels FORMAT="E:WIPMATX.ZPL" _QUANTITY="1" _PRINTERNAME="Printer
    1" _JOBNAME="LBL101">
    <label>
    <variable name="$$WIP_ENTITY_NAME$$">BLFTOP</variable>
    <variable name="$$WIP_ENTITY_NAME$$">BLFTOP14</variable>
    <variable name="COM">19AWG</variable>
    <variable name="LOT_NUMBER"></variable>
    <variable name="ASSEMBLY">A05A0084-1</variable>
    <variable name="QUANTITY_ISSUED">0</variable>
    </label>
    </labels>
    *Wrong Output:*
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels _FORMAT="E:WIPMAT_X.ZPL" _QUANTITY="1" _PRINTERNAME="Printer
    1" _JOBNAME="LBL101">
    <label>
    <variable name="$$WIP_ENTITY_NAME$$"> BLFTOP </vari
    </variable>
    <variable name="$$WIP_ENTITY_NAME$$"> BLFTOP
    BLFTOP14</variable>
    <variable name="COM">19AWG</variable>
    <variable name="LOT_NUMBER"></variable>
    <variable name="ASSEMBLY">A05A0084-1</variable>
    <variable name="QUANTITY_ISSUED">0</variable>
    </label>
    </labels>
    And Actually i am trying to generate this output format type because , wer are using Zebra Printer to print lable and it is a XML enabled bprinter and understand this specifice XML DTD type. We found when set Output type to XML, it was not generating XML in accordance with DTD which Zebra printer understand Hence we are tring to use TEXT output.
    Please suggest.
    Edited by: user5499188 on Oct 3, 2011 12:12 AM
    Edited by: user5499188 on Oct 3, 2011 12:13 AM
    Edited by: user5499188 on Oct 3, 2011 12:14 AM
    Edited by: user5499188 on Oct 3, 2011 12:23 AM

    I get the solution for this issue.
    The solution is to use XML Publisher etext temaplate.
    Etext is used to get text output in any format.
    Regards, :)

  • WRONG OUTPUT

    Hi all,
    i am getting wrong output when executing the below code
    i.e the output is coming regard less of the order number  in select statement.
    Kindly please help me.
    REPORT  ZTEMP2.
    TYPES: BEGIN OF TY_BKPF,
           MONAT TYPE MONAT,
           BUDAT TYPE BUDAT,
           BELNR TYPE BELNR_D,
           GJAHR TYPE GJAHR,
           BUKRS TYPE BUKRS,
    END OF TY_BKPF.
    TYPES: BEGIN OF TY_BSEG,
           BUKRS TYPE BUKRS,
           BELNR TYPE BELNR_D,
           GJAHR TYPE GJAHR,
           HKONT TYPE HKONT,
           WRBTR TYPE WRBTR,
           SGTXT TYPE SGTXT,
           AUFNR TYPE AUFNR,
    END OF TY_BSEG.
    TYPES: BEGIN OF TY_COLL,
           MONAT TYPE MONAT,
           BUDAT TYPE BUDAT,
           BELNR TYPE BELNR_D,
           WRBTR TYPE WRBTR,
           SGTXT TYPE SGTXT,
    END OF TY_COLL.
    DATA: TOT LIKE BSEG-WRBTR.
    DATA: IT_BKPF TYPE TABLE OF TY_BKPF,
          WA_BKPF TYPE TY_BKPF,
          IT_BSEG TYPE TABLE OF TY_BSEG,
          WA_BSEG TYPE TY_BSEG,
          IT_COLL TYPE TABLE OF TY_COLL,
          WA_COLL TYPE TY_COLL.
    SELECTION-SCREEN: BEGIN OF BLOCK B1.
    SELECT-OPTIONS: S_HKONT FOR WA_BSEG-HKONT memory id one,
                    S_AUFNR FOR WA_BSEG-AUFNR memory id twq,
                    S_BELNR FOR WA_BKPF-BELNR memory id twe,
                    S_BUDAT FOR WA_BKPF-BUDAT memory id two.
    SELECTION-SCREEN: END OF BLOCK B1.
    START-OF-SELECTION.
    SELECT MONAT
           BUDAT
           BELNR
           GJAHR
           BUKRS FROM BKPF
           INTO TABLE IT_BKPF
           WHERE BELNR IN S_BELNR
           AND  BUDAT IN S_BUDAT.
    IF NOT IT_BKPF[] IS INITIAL.
      SELECT BUKRS
             BELNR
             GJAHR
             HKONT
             WRBTR
             SGTXT
             AUFNR FROM BSEG
             INTO TABLE IT_BSEG
             FOR ALL ENTRIES IN IT_BKPF
             WHERE HKONT IN S_HKONT
             AND AUFNR IN S_AUFNR
             AND BELNR IN S_BELNR
             AND GJAHR = IT_BKPF-GJAHR
             AND BUKRS = IT_BKPF-BUKRS.
    ENDIF.
    END-OF-SELECTION.
    SORT IT_BKPF BY MONAT.
    SORT IT_BSEG BY HKONT.
    LOOP AT IT_BKPF INTO WA_BKPF.
    Read table IT_BSEG INTO WA_BSEG WITH KEY BUKRS = WA_BKPF-BUKRS
                                             BELNR = WA_BKPF-BELNR
                                             GJAHR = WA_BKPF-GJAHR BINARY SEARCH.
    WA_COLL-BELNR = WA_BKPF-BELNR.
    WA_COLL-BUDAT = WA_BKPF-BUDAT.
    WA_COLL-WRBTR = WA_BSEG-WRBTR.
    WA_COLL-SGTXT = WA_BSEG-SGTXT.
    WA_COLL-MONAT = WA_BKPF-MONAT.
    COLLECT WA_COLL INTO IT_COLL.
    CLEAR: WA_BKPF, WA_BSEG.
    ENDLOOP.
    SORT IT_COLL BY MONAT.
    LOOP AT IT_COLL INTO WA_COLL.
        WRITE:/06 WA_COLL-BELNR,
               22 WA_COLL-BUDAT,
               32 WA_COLL-WRBTR,
               54 WA_COLL-SGTXT.
        AT end of MONAT.
          SUM.
          WRITE:/ WA_COLL-MONAT.
          WRITE:32 WA_COLL-WRBTR.
        ENDAT.
    ENDLOOP.
    Thanks in advance,
    ben2012.

    Hi,
    I tried this way to calculcate opening balance,
    but it is not working kindly suggest me.
    REPORT  ZTEMP1.
    " Types Declaration part
    TYPES: BEGIN OF TY_COLL,
           MONAT TYPE MONAT,
           BUDAT TYPE BUDAT,
           BELNR TYPE BELNR_D,
           WRBTR TYPE WRBTR,
           SGTXT TYPE SGTXT,
           TOT TYPE WRBTR,
    END OF TY_COLL.
    DATA: TOT LIKE BSEG-WRBTR.
    DATA: IT_BKPF TYPE TABLE OF TY_BKPF,
          WA_BKPF TYPE TY_BKPF,
          IT_BSEG TYPE TABLE OF TY_BSEG,
          WA_BSEG TYPE TY_BSEG,
          IT_BKPF1 TYPE TABLE OF TY_BKPF1,
          WA_BKPF1 TYPE TY_BKPF1,
          IT_BSEG1 TYPE TABLE OF TY_BSEG1,
          WA_BSEG1 TYPE TY_BSEG1,
          IT_COLL TYPE TABLE OF TY_COLL,
          WA_COLL TYPE TY_COLL.
    SELECTION-SCREEN: BEGIN OF BLOCK B1.
    SELECT-OPTIONS: S_HKONT FOR WA_BSEG-HKONT memory id one,
                    S_AUFNR FOR WA_BSEG-AUFNR memory id twq,
                    S_BELNR FOR WA_BKPF-BELNR memory id twe,
                    S_BUDAT FOR WA_BKPF-BUDAT memory id two.
    SELECTION-SCREEN: END OF BLOCK B1.
    START-OF-SELECTION.
    PERFORM SELECT1.
    PERFORM OPB.
    END-OF-SELECTION.
    PERFORM P_SELECT1.
    PERFORM P_OPB.
    PERFORM P_COLL.
    *&      Form  SELECT1
    FORM SELECT1 .
    SELECT MONAT
           BUDAT
           BELNR
           GJAHR
           BUKRS FROM BKPF
           INTO TABLE IT_BKPF
           WHERE BELNR IN S_BELNR
           AND  BUDAT IN S_BUDAT.
    IF NOT IT_BKPF[] IS INITIAL.
      SELECT BUKRS
             BELNR
             GJAHR
             HKONT
             WRBTR
             SGTXT
             AUFNR FROM BSEG
             INTO TABLE IT_BSEG
             FOR ALL ENTRIES IN IT_BKPF
             WHERE HKONT IN S_HKONT
             AND AUFNR IN S_AUFNR
             AND BELNR = IT_BKPF-BELNR
             AND GJAHR = IT_BKPF-GJAHR
             AND BUKRS = IT_BKPF-BUKRS.
    ENDIF.
    ENDFORM.                    " SELECT1
    *&      Form  OPB
    FORM OPB .
    SELECT MONAT
           BUDAT
           BELNR
           GJAHR
           BUKRS FROM BKPF
           INTO TABLE IT_BKPF1
           WHERE BELNR IN S_BELNR
           AND  BUDAT < S_BUDAT+3(8).
    IF NOT IT_BKPF1[] IS INITIAL.
      SELECT BUKRS
             BELNR
             GJAHR
             HKONT
             WRBTR
             SGTXT
             AUFNR FROM BSEG
             INTO TABLE IT_BSEG1
             FOR ALL ENTRIES IN IT_BKPF1
             WHERE HKONT IN S_HKONT
             AND AUFNR IN S_AUFNR
             AND BELNR = IT_BKPF1-BELNR
             AND GJAHR = IT_BKPF1-GJAHR
             AND BUKRS = IT_BKPF1-BUKRS.
    ENDIF.
    ENDFORM.                    " OPB
    *&      Form  P_SELECT1
    FORM P_SELECT1 .
    SORT IT_BKPF BY MONAT.
    SORT IT_BSEG BY HKONT.
    LOOP AT IT_BSEG INTO WA_BSEG.
      READ TABLE IT_BKPF INTO WA_BKPF WITH KEY BUKRS = WA_BSEG-BUKRS
                                               BELNR = WA_BSEG-BELNR
                                               GJAHR = WA_BSEG-GJAHR BINARY SEARCH.
    IF sy-subrc EQ 0.
    WA_COLL-BELNR = WA_BKPF-BELNR.
    WA_COLL-BUDAT = WA_BKPF-BUDAT.
    WA_COLL-WRBTR = WA_BSEG-WRBTR.
    WA_COLL-SGTXT = WA_BSEG-SGTXT.
    WA_COLL-MONAT = WA_BKPF-MONAT.
    COLLECT WA_COLL INTO IT_COLL.
    endif.
    CLEAR: WA_BKPF, WA_BSEG.
    ENDLOOP.
    ENDFORM.                    " P_SELECT1
    *&      Form  P_OPB
    FORM P_OPB .
    SORT IT_BKPF1 BY MONAT.
    SORT IT_BSEG1 BY HKONT.
    LOOP AT IT_BSEG1 INTO WA_BSEG1.
      READ TABLE IT_BKPF1 INTO WA_BKPF1 WITH KEY BUKRS = WA_BSEG1-BUKRS
                                                 BELNR = WA_BSEG1-BELNR
                                                 GJAHR = WA_BSEG1-GJAHR BINARY SEARCH.
    IF sy-subrc EQ 0.
    WA_COLL-TOT = WA_BSEG1-WRBTR.
    COLLECT WA_COLL INTO IT_COLL.
    endif.
    CLEAR: WA_BKPF1, WA_BSEG1.
    ENDLOOP.
    ENDFORM.                    " P_OPB
    *&      Form  P_COLL
    FORM P_COLL .
    SORT IT_COLL BY MONAT.
    LOOP AT IT_COLL INTO WA_COLL.
        WRITE:/06 WA_COLL-BELNR,
               22 WA_COLL-BUDAT,
               32 WA_COLL-WRBTR,
               54 WA_COLL-SGTXT.
        AT end of MONAT.
          SUM.
          WRITE:/ WA_COLL-MONAT.
          WRITE:32 WA_COLL-WRBTR.
          WRITE: WA_COLL-TOT.  " getting value 0
        ENDAT.
    ENDLOOP.
    ENDFORM.                    " P_COLL

  • How to redirect output of an OS command to a stream???

    how can i redirect the output of an OS command (such as 'ls' in linux or 'dir' in windows) to a io stream???
    ....for example, assume i'm having a textbox and a button...when i click the button , i need the output of 'ls' to be in the textbox....i think execution of the command could be accomplished by Runtime's exec() ...but how to redirect outputs???

    You should find what you are looking for here:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Output format of sqlplus commands under shell script

    hi experts
    Can you help with some problems please?
    1.) I try to run shell script from dbms_scheduler, which runs sqlplus and the output of sqlplus commands is written to file using command spool. To this point everything is running ok.
    My problem is, that output of this file is: (e.g.)
    SQL> PROMPT ****************USERB******************
    ****************USERB******************
    SQL> --SELECT sid
    SQL> -- FROM v
    SQL> -- WHERE audsid = SYS_CONTEXT('userenv','sessionid');
    But I don't want the whole first line in the output file. I only want the output of this command, like on the second line.
    2.) How Can I write two outputs from sqlplus using command spool running at the same time into one file?
    Like in first issue described above. The main sqlplus create a job and this execute the background sqlplus using shell script. But both, the main and the background sqlplus are written to output file at the same time. But only one is written into. But I want the both outputs in the file.
    How Can I do that, if I can?
    Thanks a lot.

    user9357436 wrote:
    hi experts
    Can you help with some problems please?
    1.) I try to run shell script from dbms_scheduler, which runs sqlplus and the output of sqlplus commands is written to file using command spool. To this point everything is running ok. then why are you here?
    My problem is, that output of this file is: (e.g.)
    SQL> PROMPT ****************USERB******************
    ****************USERB******************so remove PROMPT line from the file
    >
    SQL> --SELECT sid
    SQL> -- FROM v
    SQL> -- WHERE audsid = SYS_CONTEXT('userenv','sessionid');
    But I don't want the whole first line in the output file. I only want the output of this command, like on the second line.
    2.) How Can I write two outputs from sqlplus using command spool running at the same time into one file?you can not do so.
    Like in first issue described above. The main sqlplus create a job and this execute the background sqlplus using shell script. But both, the main and the background sqlplus are written to output file at the same time. But only one is written into. But I want the both outputs in the file.
    How Can I do that, if I can?Can't.
    Now what?
    >
    Thanks a lot.Why using DBMS_SCHEDULER to invoke OS script to run sqlplus that runs SQL statements?
    this is like making THREE Left Turns, instead of single Right Turn.
    Just invoke PL/SQL procedure that does what needs to be done.

  • Wrong output from filter

    Hi everyone, 
    I'm using an equi-ripple bandpass filter for my ECG signal and getting wrong outputs. Any idea why?
    Regards,
    Gerard
    Attachments:
    filter.JPG ‏10 KB

    Hi Gerard,
    What kind of wrong outputs are you getting with the filter?  Furthermore what kind of signal are you getting from your ECG signal?  Would it be possible to put the vi on the discussion forum?
    Regards
    Nadim
    Applications Engineering
    National Instruments

  • Java Wrong Output

    After two weeks I finally got my project to run only its not outputting all the information that is suppose to.
    My output should display the dollar amount along with the tax catergory, but its only displaying the tax category, can someone please assist me in locating what am doing wrong.
    Correct Output: The tax rate category for an annual salary of 34400 is 3.
    My Ouput: The tax rate category for annual salary of 6
    * AnnualSalary.java
    * Johnise Felder
    * This program should display the annual salary and tax category.
    package annualsalary;
    * @author felde301
    import javax.swing.JOptionPane;
    public class AnnualSalary {
    /** Creates a new instance of AnnualSalary */
    public AnnualSalary() {
    * @param args the command line arguments
    public static void main(String[] args) {
         float annualsalary = 0;
         int taxratecategory = 0;
         String input =
    JOptionPane.showInputDialog (null,"Enter an annual salary",
         "Input Dialog Demo",
    JOptionPane.QUESTION_MESSAGE);
    annualsalary = Integer.parseInt(input);
    if (annualsalary < 15000){
    taxratecategory = 1;
    else if (annualsalary > 15000 && annualsalary < 25000)
    taxratecategory = 2;
    else if (annualsalary > 25001 & annualsalary < 40000)
    taxratecategory = 3;
    else if (annualsalary > 400001 & annualsalary < 65000)
    taxratecategory = 4;
    else if (annualsalary > 65001 & annualsalary < 80000)
    taxratecategory = 5;
    else if (annualsalary > 80000)
    taxratecategory = 6;
    //end if
    //display the result
    JOptionPane.showMessageDialog(null,"The tax rate category for an annual salary of:" + taxratecategory);
    }

    hi,
    take your modified code
    * AnnualSalary.java
    * Johnise Felder
    * This program should display the annual salary and tax category.
    package annualsalary;
    * @author felde301
    import javax.swing.JOptionPane;
    public class AnnualSalary {
    /** Creates a new instance of AnnualSalary */
    public AnnualSalary() {
    * @param args the command line arguments
    public static void main(String[] args) {
    float annualsalary = 0;
    int taxratecategory = 0;
    String input =
    JOptionPane.showInputDialog (null,"Enter an annual salary",
    "Input Dialog Demo",
    JOptionPane.QUESTION_MESSAGE);
    annualsalary = Integer.parseInt(input);
    if (annualsalary < 15000){
    taxratecategory = 1;
    else if (annualsalary >= 15000 && annualsalary <= 25000)
    taxratecategory = 2;
    else if (annualsalary >= 25001 && annualsalary <= 40000)
    taxratecategory = 3;
    else if (annualsalary >= 400001 && annualsalary <= 65000)
    taxratecategory = 4;
    else if (annualsalary > 65001 && annualsalary <= 80000)
    taxratecategory = 5;
    else if (annualsalary >= 80000)
    taxratecategory = 6;
    //end if
    //display the result
    JOptionPane.showMessageDialog(null,"The tax rate category for an annual salary of:" + taxratecategory);
    }

  • How to remove truncation in the output of ps -ef command in solaris

    Hi,
    One silly question but i m unable to find solution.
    In solaris-10 when i executed the command ps -ef some datas in the output in the command column is truncated as below
    UID PID PPID C STIME TTY TIME CMD
    root 6811 1 0 19:33:36 pts/3 0:00 sh /export/home/bti/bti/Revathi/BTI/EMS/bin/startemsserver.sh
    root 6827 6819 0 19:33:37 pts/3 2:33 /export/home/bti/bti/Revathi/BTI/EMS/jre/bin/java -DJBOSS_HOME=/export/home/bti
    Where in the CMD column the path */export/home/bti/bti/Revathi/BTI/EMS/jre/bin/java -DJBOSS_HOME=/export/home/bti* continues. Only half of the path is shown. I need the entire path how to achieve it
    Regards
    Revathi

    Just to make things a little more complex...
    /usr/ucb/ps (actually /usr/ucb/sparcv9/ps) used to be SUID root so that it could read the full args directly out of the address space of the process (/proc/<pid>/as).
    Sun removed this behavior in Solaris 8 with patch 109023-05 and in Solaris 9 with patch 120240-01 (it's been removed from Solaris 10 since FCS)

  • Output jframe information to command window

    Hi all I have a program that tracks the assets of a customer, kind of like a cart that holds cds, appliances, etc...
    I wanted to be able to print out the results to the command window after they enter the number of how many items from what the user enters after they press "current status" or if they "delete" their current items. I want it to keep doing this until they close the window and exit the program. People have told me to add the System.out.println to where it says "delete" or "current status" but Im not sure how to add it in I will attach the code here. Thanks
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class TestProgram extends JFrame implements ActionListener{
       JLabel column1, column2;
       JLabel totalItems, totalCost;
       JLabel serialNum;
       JLabel electronics, autos, furnitures, cds;
       JButton TrackAssets, delete;
       JPanel panel;
       JTextField electronicsAsset, autosAsset, furnituresAsset, cdsAsset;
       JTextField serialNumber;
       JTextArea items, cost;
       // constructor to initialize the top variables/fields
       public TestProgram()
             column1 = new JLabel("Select Items");
         column2 = new JLabel("Specify Quantity");
         electronics = new JLabel("Electronics");
         electronicsAsset = new JTextField();
         electronicsAsset.addActionListener(this);
         autos = new JLabel("Autos");
         autosAsset = new JTextField();
         autosAsset.addActionListener(this);
         furnitures = new JLabel("Furnitures");
         furnituresAsset = new JTextField();
         furnituresAsset.addActionListener(this);
         cds = new JLabel("Compact Discs");
         cdsAsset = new JTextField();
         cdsAsset.addActionListener(this);
         serialNum = new JLabel("Serial Number input here");
         serialNumber = new JTextField();
         electronicsAsset.setNextFocusableComponent(serialNumber);
    //Create labels and text area components
         totalItems = new JLabel("Total Items:");
         totalCost = new JLabel("Total Cost:");
         items = new JTextArea();
         cost = new JTextArea();
    //Create buttons and make action listeners
         TrackAssets = new JButton("Current Status");
         TrackAssets.addActionListener(this);
         delete = new JButton("Delete all");
         delete.addActionListener(this);
    //Create a panel for the components
         panel = new JPanel();
    //Set panel layout to 2-column grid
    //on a white
         panel.setLayout(new GridLayout(0,4));
         panel.setBackground(Color.white);
    // add details
         getContentPane().add(panel);
         panel.add(column1);
         panel.add(column2);
         panel.add(electronics);
         panel.add(electronicsAsset);
         panel.add(autos);
         panel.add(autosAsset);
          panel.add(furnitures);
          panel.add(furnituresAsset);
          panel.add(cds);
          panel.add(cdsAsset);
         panel.add(furnitures);
         panel.add(furnituresAsset);
         panel.add(totalItems);
         panel.add(items);
         panel.add(totalCost);
         panel.add(cost);
         panel.add(serialNum);
         panel.add(serialNumber);
         panel.add(delete);
         panel.add(TrackAssets);
       public void actionPerformed( ActionEvent event ){
                 // variables for method actionPerformed
                 String output, output2;
                 Object source = event.getSource();
                 Integer electronicsNo, autosNo, furnituresNo, cdsNo, serialNum;
                 // class responsible for showing different items
                 AssetTracker tracker = new AssetTracker();
                 Double cost;
                 // program is instance of TestProgram creates a new file
                 TestProgram program = new TestProgram();
                // if they track assets...
                if(source == TrackAssets){
                  tracker.serialNum = serialNumber.getText();
                  tracker.electronics = electronicsAsset.getText();
                  tracker.autos = autosAsset.getText();
                  tracker.furnitures = furnituresAsset.getText();
                  tracker.cds = cdsAsset.getText();
             if(tracker.electronics.length() > 0){
                       //statement that might throw an exception
                       try{
                           electronicsNo = Integer.valueOf(tracker.electronics);
                           tracker.itotal += electronicsNo.intValue();
                         //find invalid number     
                         catch(java.lang.NumberFormatException e){
                           electronicsAsset.setText("Invalid Value");
                       else {
                             tracker.itotal += 0;
             if(tracker.autos.length() > 0){
                        //find invalid again
                         try{
                      autosNo = Integer.valueOf(tracker.autos);
                      tracker.itotal += autosNo.intValue();
               catch(java.lang.NumberFormatException e){
                      System.out.println("Invalid Value");
             else {
          tracker.itotal += 0;
        if(tracker.furnitures.length() > 0){
           //seek invalid numbers
         //statement that might throw an exception.
          try{
            furnituresNo = Integer.valueOf(tracker. furnitures);
            tracker.itotal +=  furnituresNo.intValue();
        // statements to be executed if a matching Java exception occurs in try.
          catch(java.lang.NumberFormatException e){
             furnituresAsset.setText("Invalid Value");
             else {
          tracker.itotal += 0;
        if(tracker.cds.length() > 0){
         //check then find invalid
          try{
            cdsNo = Integer.valueOf(tracker.cds);
            tracker.itotal += cdsNo.intValue();
          catch(java.lang.NumberFormatException e){
            cdsAsset.setText("Invalid Value");
          else {
          tracker.itotal += 0;
        // display
         serialNum = new Integer(tracker.itotal);
         output = serialNum.toString();
         this.items.setText(output);
         tracker.icost = (tracker.itotal * 300.00);
         cost = new Double(tracker.icost);
         output2 = cost.toString();
         this.cost.setText(output2);
       // electronics, autos, furnitures, cds
       // if user delete all items from assets
       if(source == delete){
         serialNumber.setText("");
         electronicsAsset.setText("");
         autosAsset.setText("");
         furnituresAsset.setText("");
         cdsAsset.setText("");
         serialNumber.setText("");
         tracker.icost = 0;
         cost = new Double(tracker.icost);
         output2 = cost.toString();
         this.cost.setText(output2);
         tracker.itotal = 0;
         serialNum = new Integer(tracker.itotal);
         output = serialNum.toString();
         this.items.setText(output);
      // main method
      public static void main( String[] args )
            TestProgram frame = new TestProgram();
              // title of JFrame
              frame.setTitle("Asset tracking program");
            // mew window created
            WindowListener l = new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                            System.exit(0);// exit
            // add window from package then show window
            frame.addWindowListener(l);
            frame.pack();
            frame.setVisible(true);

    I don't understand the question. Are you telling us you don't understand how to use System.out.println(...);? How do you debug programs without using this method?
    Usually the first program someone learns to write is something like:
    public static void main(String[] args)
        System.out.println("Hello World");
    after they press "current status" or if they "delete" their current itemsYou want to do some activity when the above actions occur. You must already have code in your program to do something in the above cases. So simply add the System.out.println(..) statements in the same part of code.

  • Output plsql variable to command window

    I am executing a PLSQL stored procedure from my java class. I want to know how to output a variable within the PLSQL to the command window?
    thanks

    I don't understand the question. Are you telling us you don't understand how to use System.out.println(...);? How do you debug programs without using this method?
    Usually the first program someone learns to write is something like:
    public static void main(String[] args)
        System.out.println("Hello World");
    after they press "current status" or if they "delete" their current itemsYou want to do some activity when the above actions occur. You must already have code in your program to do something in the above cases. So simply add the System.out.println(..) statements in the same part of code.

  • Why did Solaris 10 X86 change the output of the format command?

    Solaris 8,9, & 10 for Sparc all display disk manufacturer information on the format command output:
    0. c1t0d0 <SUN36G cyl 24620 ... >
    1. c1t1d0 <SEAGATE-ST3360704FSUN36G-0826 cyl 24620 ... >
    But for X86 this information is not displayed:
    0. c1t0d0 <DEFAULT cyl 17846 ... >
    1. c1t1d0 <DEFAULT cyl 17846 ... >
    We need to read this programatically to distinguish certain physical drives. What happened to this information? Is this a bug?

    Solaris 8,9, & 10 for Sparc all display disk
    manufacturer information on the format command
    output:
    0. c1t0d0 <SUN36G cyl 24620 ... >
    1. c1t1d0 <SEAGATE-ST3360704FSUN36G-0826 cyl 24620
    ... > I believe this information is in the disk label. I think on first label some of that information can be queried, but it doesn't always reflect the actual disk.
    But for X86 this information is not displayed:
    0. c1t0d0 <DEFAULT cyl 17846 ... >
    1. c1t1d0 <DEFAULT cyl 17846 ... >'format' on x86 is only looking at one fdisk-style slice, not the physical disk.
    We need to read this programatically to distinguish
    certain physical drives. What happened to this
    information? Is this a bug?More information does appear in some situations, but I'm not sure where it's querying the information. Again, the label is not a good indicator of what the physical disk is, because that data can be copied.
    You might try 'iostat -En' and see if that has sufficient information.
    Darren

  • Not getting full output  through prtdiag -v command

    Dear all
    I am not getting the "Environmental Status", "FRU Status" & "FW Version:" through prtdiag -v command. Here is the output of the command :
    # prtdiag -v
    System Configuration: Sun Microsystems sun4v SPARC Enterprise T5220
    Memory size: 32640 Megabytes
    ================================ Virtual CPUs ================================
    CPU ID Frequency Implementation Status
    0 1167 MHz SUNW,UltraSPARC-T2 on-line
    1 1167 MHz SUNW,UltraSPARC-T2 on-line
    2 1167 MHz SUNW,UltraSPARC-T2 on-line
    3 1167 MHz SUNW,UltraSPARC-T2 on-line
    61 1167 MHz SUNW,UltraSPARC-T2 on-line
    62 1167 MHz SUNW,UltraSPARC-T2 on-line
    63 1167 MHz SUNW,UltraSPARC-T2 on-line
    ======================= Physical Memory Configuration ========================
    Segment Table:
    Base Segment Interleave Bank Contains
    Address Size Factor Size Modules
    0x0 32 GB 8 4 GB MB/CMP0/BR0/CH0/D0
    MB/CMP0/BR0/CH1/D0
    4 GB MB/CMP0/BR0/CH0/D1
    MB/CMP0/BR0/CH1/D1
    4 GB MB/CMP0/BR1/CH0/D0
    MB/CMP0/BR1/CH1/D0
    4 GB MB/CMP0/BR1/CH0/D1
    MB/CMP0/BR1/CH1/D1
    4 GB MB/CMP0/BR2/CH0/D0
    MB/CMP0/BR2/CH1/D0
    4 GB MB/CMP0/BR2/CH0/D1
    MB/CMP0/BR2/CH1/D1
    4 GB MB/CMP0/BR3/CH0/D0
    MB/CMP0/BR3/CH1/D0
    4 GB MB/CMP0/BR3/CH0/D1
    MB/CMP0/BR3/CH1/D1
    ========================= IO Configuration =========================
    IO
    Location Type Slot Path Name Model
    MB/PCIE PCIE MB /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0 pci-pciexclass,060400
    MB/NET0 PCIE MB /pci@0/pci@0/pci@1/pci@0/pci@2/network@0 network-pciex8086,105e
    MB/NET1 PCIE MB /pci@0/pci@0/pci@1/pci@0/pci@2/network@0,1 network-pciex8086,105e
    MB/NET2 PCIE MB /pci@0/pci@0/pci@1/pci@0/pci@3/network@0 network-pciex8086,105e
    MB/NET3 PCIE MB /pci@0/pci@0/pci@1/pci@0/pci@3/network@0,1 network-pciex8086,105e
    MB/PCIE PCIE MB /pci@0/pci@0/pci@2/scsi@0 scsi-pciex1000,58 LSI,1068E
    MB/PCIE1 PCIE 1 /pci@0/pci@0/pci@8/pci@0/pci@1/SUNW,emlxs@0 SUNW,emlxs-pci10df,fc20LPe11000-S
    MB/PCIE0 PCIE 0 /pci@0/pci@0/pci@8/pci@0/pci@9/SUNW,emlxs@0 SUNW,emlxs-pci10df,fc20LPe11000-S
    ========================= HW Revisions =======================================
    System PROM revisions:
    OBP 4.27.1 2007/09/14 15:17
    IO ASIC revisions:
    Location Path Device Revision
    MB/PCI-SWITCH0 /pci@0/pci@0 pciex10b5,8533.aa 170
    MB/PCI-SWITCH2 /pci@0/pci@0/pci@1/pci@0 pciex10b5,8517.ad 173
    MB/PCI-SWITCH1 /pci@0/pci@0/pci@8/pci@0 pciex10b5,8533.aa 170
    MB/GBE0 /pci@0/pci@0/pci@1/pci@0/pci@2/network@0 pciex8086,105e.108e.105e.6 6
    MB/GBE0 /pci@0/pci@0/pci@1/pci@0/pci@2/network@0,1 pciex8086,105e.108e.105e.6 6
    MB/GBE1 /pci@0/pci@0/pci@1/pci@0/pci@3/network@0 pciex8086,105e.108e.105e.6 6
    MB/GBE1 /pci@0/pci@0/pci@1/pci@0/pci@3/network@0,1 pciex8086,105e.108e.105e.6 6
    MB/SAS-SATA-HBA /pci@0/pci@0/pci@2/scsi@0 pciex1000,58.1000.1000.2 2
    Kindly help me in getting that information from prtdiag command as I have check that picld deamon is running on the system also & service is in online status . This system is running solaris 10 OS.
    Regards

    Hi
    I would like to know if I restart the picl service in solaris 10 on production server, will it have any effect on the production server. As I think that may be, I will get the proper output after restarting the daemon.
    Regards

Maybe you are looking for