How to Redirect a Unix program to output to Java not a log

Hi all!
Okay, here is what I am trying and I cannot seem to get a handle on where I should start.
I have a Unix program that basically outputs to a log file when a error occurs. (std_err_file: /Errorfile)
What I am trying to do is have this entry redirected to a java program that will take the log stream and then use it in some fashion. Perhaps (std_err_file: >java readlog Errorfile)? Not sure if this will work, and I need to get a better understanding of what type of stream to use to read this data.
Can anyone give me a pointer in the "write" direction??
Thanks in advance...

Just read it in like you would keyboard input.
Programs have three IO streams permanently attached
Standard In (stdin) is an Input Stream.
Standard Out (stdout) is an Output Stream.
Standard Error (stderr) is a Second Output Stream.
Think of it this way:
Each STDxxx is like a hose. When you invoke a program, by default the
hoses are attached as follows:
stdin is attached to the keyboard for input.
stdout is attached to the console window for output.
stderr is attached to the console window for output.
In java, the streams System.in, System.out, System.err are the other ends of these hoses.
Now, in Unix (and similarly in dos or NTshell) you can connect these hoses in different ways using a "pipe" (hence the hose metaphor)
'Program1 | Program2' will take the stdout stream from Program1, and disconnect it from the console window. It will also disconnect the stdin stream from the keyboard, and then, it will slip in a piece of pipe between the two hoses, thus connecting them.
So, program2 can read the output on its System.in stream in exactly the same way as it would if it was connected to the keyboard. In fact, Program2 has absolutely no knowledge of what is at the other end of that hose, just that there is data coming down it.
So, the leaves us with the question "What is stderr for?" It's for error messages. It is often convenient to use a pipe or a file redirect (similar to a pipe) to send data to a file, but errors to the screen.
A programmer can facilite this by sending all true output to System.out, and all error messages to System.err
Example: (in class Bob)
System.out.println("Hello Bob");
System.err.println("Warning: Bob is hacking again.");
java Bob | someProgram
// pipe the stdout of Bob to someProgram
// leave stderr attached to the keyboard.
Will send the message Hello Bob to someProgram, but the Error message will appear on the console for the system administrator to read.
Do a google on "Pipes and redirects" for more info.

Similar Messages

  • How to execute a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say the Perl program that I want to execute is 'abc'. Now, 'abc' requires some input that I want to give it from within the Java program. How do I do it?
    And finally, how do I execute that Perl program from within the Java program.
    If I execute the Perl program alone then I do it in the following way -
    perl abc inp1 inp2 inp3
    where inp1, inp2, inp3 are inputs to the Perl program. I will not be able to change or modify the coding of the Perl program - 'abc' as I do not have access to its code. Its a kind of an application whose usual method of execution is in the above shown way. So, how do I execute 'abc' from within a Java program.

    what part of don't crosspost, don't you understand?
    http://forum.java.sun.com/thread.jsp?forum=4&thread=427193

  • How to call a unix program which is  IRIX OS from java

    Hi,
    I have a program on UNIX platform and OS is IRIX. I have a java program on WINDOWS machine. I want to run that program, which is on UNIX paltform from java. I know the path but I am not able to give that path using Runtime.exec() command.I can run any file on the WINDOWS machine using my JAVA program. Can anybody help me ???

    I am not really sure if I understood your problem, but it might have something to do with forgetting to set the LD_LIBRARY_PATH.
    Set this path according to your needed paths and maybe this already solved your problems.
    Greetings,
    John

  • How can I use UNIX "ls -lt" command in JAVA?

    I have a piece of java code whose function is to search for all
    the files in a directory and attach the time of the file creation.
    How can I do it? Also, I know that in UNIX, "ls -lt" will give me
    all the file names and the creation times. So how can I use "ls -lt"
    in Java?

    O,I see you have notice my friend tsith,its not really about what language is better its about what language is better to start off with,this is the twist and the diffrents to other postings and so far I have not seen a good argument saying y java is a better language to start off with.Anyways the ? still stands is java a better language to start off with then c/c++???.If you ask me c/c++ is better and I am just waiting for a good argument to give my reasons.Anysways good to see you are still around tsith ;-).

  • How can I get windows to save "FILE~1 JAV" not ~1  TXT

    HOw can I get windows to save my program HELLOW~1 JAV and not HELLOW~1 TXT? When I look all the way to the right the file also says "HelloWorld.java.txt" is that right?

    OK thanks everyone I just compiled my first program ..HELLO WORLD ... lol....i know its nothing to most of you but its a great accomplishment for me...I also wann thanks Foxylady ..she was right .... i had to place "" on the file to save it ...thanks again everyone!!

  • How to get check box in alv output

    hi gurus
    can anyone explian me how to get check box in alv output
    it should not be a pop up window
    i want to get in output itself
    tahnk you
    regards
    kals.

    Hi
    by using rs_selfield
    ty to call dynamic subroutine..
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    read table rs-selfield with key cond = 'X'
    endform.
    see the below example
    REPORT Z_GET_REFRESH no standard page heading.
    type-pools : slis.
    tables : makt,
    mara.
    data : i_fieldcat type slis_t_fieldcat_alv.
    CONSTANTS :
    gc_refresh TYPE syucomm VALUE '&REFRESH'.
    data : begin of i_makt occurs 0,
    matnr like makt-matnr,
    maktx like makt-maktx,
    end of i_makt.
    data : v_repid like sy-repid,
    g_user_command type slis_formname value 'USER_COMMAND',
    g_status_set type slis_formname value 'SET_PF_STATUS',
    lt_event_exit TYPE slis_t_event_exit,
    ls_event_exit TYPE slis_event_exit.
    DATA:LC_GLAY TYPE LVC_S_GLAY.
    select-options s_matnr for mara-matnr .
    start-of-selection.
    select matnr maktx from makt into table i_makt
    where matnr in s_matnr.
    end-of-selection.
    Fill the fieldcatlog
    perform fill_field.
    Call the FM
    perform call_fm.
    *& Form fill_field
    text
    --> p1 text
    <-- p2 text
    FORM fill_field.
    data wa_fieldcat type slis_fieldcat_alv.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-outputlen = '18'.
    wa_fieldcat-seltext_l = 'Material #'.
    wa_fieldcat-col_pos = '1'.
    append wa_fieldcat to i_fieldcat.
    clear : wa_fieldcat.
    wa_fieldcat-tabname = 'I_MAKT'.
    wa_fieldcat-fieldname = 'MAKTX'.
    wa_fieldcat-outputlen = '40'.
    wa_fieldcat-seltext_l = 'Material Desc'.
    wa_fieldcat-col_pos = '2'.
    append wa_fieldcat to i_fieldcat.
    ENDFORM. " fill_field
    *& Form call_fm
    text
    --> p1 text
    <-- p2 text
    FORM call_fm.
    v_repid = sy-repid.
    LC_GLAY-EDT_CLL_CB = 'X'.
    CLEAR ls_event_exit.
    ls_event_exit-ucomm = gc_refresh. " Refresh
    ls_event_exit-after = 'X'.
    APPEND ls_event_exit TO lt_event_exit.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = v_repid
    I_CALLBACK_PF_STATUS_SET = g_status_set
    I_CALLBACK_USER_COMMAND = g_user_command
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS = LC_GLAY
    IS_LAYOUT =
    IT_FIELDCAT = i_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT = lt_event_exit
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_ADD_FIELDCAT =
    IT_HYPERLINK =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IT_EXCEPT_QINFO =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = i_makt
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " call_fm
    FORM USER_COMMAND *
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield. "#EC CALLED
    data i_RSPARAMS like RSPARAMS occurs 0.
    CASE R_UCOMM.
    WHEN '&IC1'.
    read table i_makt index rs_selfield-tabindex.
    SET PARAMETER ID 'MAT' FIELD i_makt-matnr.
    if not i_makt-matnr is initial.
    call transaction 'MM02' and skip first screen.
    endif.
    when '&REFRESH'.
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
    CURR_REPORT = v_repid
    IMPORTING
    SP =
    TABLES
    SELECTION_TABLE = i_RSPARAMS
    EXCEPTIONS
    NOT_FOUND = 1
    NO_REPORT = 2
    OTHERS = 3
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    submit z_get_refresh with selection-table i_RSPARAMS.
    rs_selfield-refresh = 'X'.
    ENDCASE.
    MOVE '&REFRESH' TO r_ucomm.
    ENDFORM.
    FORM set_pf_status *
    FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.
    DELETE Rt_extab WHERE fcode = gc_refresh.
    SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
    EXCLUDING Rt_extab.
    *SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
    SET TITLEBAR sy-tcode.
    ENDFORM.

  • Pages 5.5 output PDF is not have pages number interlinkage ,why?How to deal with?

    pages 5.5 output PDF is not have pages number interlinkage ,why?How to deal with?

    pages 5.5 output PDF is not have pages number interlinkage ,why?How to deal with?

  • I have a password protected site in iweb, but how do I get my users to "sign out" so there not always logged in

    I built a password protected site in iweb and its published through mobileme. How do I get users to "sign out" so there not always logged in

    I wouldn't bother really - it would be best to concentrate your efforts now on finding another web host that you can move your site to because after the end of June this year, publishing to MobileMe won't be an option.
    Have a look at GoDaddy, HostExcellence etc. and you can still password protect your website, but you just do this through your host/server rather than MMe.
    Start looking now before it's too late!

  • How to submit a cuncurrent program from UNIX?

    How to submit a concurrent program from UNIX.Plz reply immediatly

    Please see;
    Oracle Metalink Document: How to Submit a Concurrent Request Using CONCSUB Syntax: Doc ID: Note:457519.1
    https://metalink.oracle.com/metalink/plsql/f?p=130:14:5250231761732667752::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,457519.1,1,1,0,helvetica
    Adith

  • How to customize the Java Concurrent Program(PO Output for Communication)

    Hi,
    How to customize the Java Concurrent Program(PO Output for Communication)
    I need to add the Line level Ship To Address ,Line Notes and Extended Price fields on Java Concurrent Program.
    Please any body help/guide me in this regard.

    Hi,
    Changing Java Conc. program for "PO Output for Communication" is difficult.
    Actually, if you observe closely, "PO Output for Communication" program uses PO<HEADER/LINES..>_XML views.
    So if you could change these views and add your requireed columns to it, you can automatically see your changes in XML data file.
    See if the following link will you to get there.. http://chandramatta.blogspot.com/
    thanks,
    Matt

  • Hello, How do I tell sql+ to spool output file from windows to Unix server?

    Hello, How do I tell sql+ to spool output file from windows to Unix server?
    I am new to SQL+ and just learned how to spool the file. But file is saved in my local windows enviroment and since it's 2GB in size...I want to spool it directly to another remote unix server.
    Pls answer in detail... I have been to most of the thread and didn't see relevant answer to above question.
    Am I suppose to develope some script which FTP the spool file directly to the server I want to
    or
    i Have to use UTL_FILE Package ?
    Thanks for reply

    You may not be able to...
    SQL*Plus can only spool to the local machine. If you have mapped a directory on the Unix server from your Windows machine, you can specify that directory in your SPOOL command.
    You could telnet to the Unix server, run SQL*Plus there, and spool the file to a local (Unix) directory.
    If the Unix server is also the Oracle database server, you could use the UTL_FILE package rather than using SQL*Plus to spool a file.
    If the Unix server is also an FTP server, you could also FTP the file from your local machine to the server.
    Of course, I would tend to re-examine a requirement to regularly generate a 2 GB text file. It seems likely that there is a better way...
    Justin

  • How to redirect CELLCLI output to text file

    Hi,
    I would like to redicrect the output of the cellcli command to a text file .
    For example , how to redirect the output of this command to a text file on /tmp
    CellCLI> list metrichistory where objectType = 'CELL' -
    and name = 'CL_TEMP'Thanks

    cellcli has spooling capabilities similar to sqlplus:
    CellCLI> help spool
      Usage:  SPO[OL] [<filename> [ CRE[ATE] | REP[LACE] | APP[END]] | OFF ]
      Purpose: SPOOL <filename>: Direct the results to the file <filename>.
               SPOOL OFF: Turn off the spooling.
               SPOOL: Check the current spooling status.
      Arguments:
        <filename>: The filename where the results will be output.
      Options:
        [APPEND]: If the filename already exists, the following output will
                  be appended to the file. Without this option, the existing file
                  contents will be replaced.
        [CREATE]: If the filename already exists, an error is reported.
        [REPLACE]: If the filename already exists, the contents will be
                  replaced.  This is the default, when no option is provided.
      Examples:
        spool myfile
        spool myfile append
        spool off
        spoolBut if you are trying to script it, it would be easier to just run it command line:
    # cellcli -e "list metrichistory where objectType = 'CELL' and name = 'CL_TEMP'" > /tmp/CL_TEMP.txtAlso look into dcli which allows you to run cellcli commands on one or more cells from a compute node.
    Good luck.

  • 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

  • How to redirect tomcat's (not in jwsdp) output  to catalina.out

    how to redirect tomcat's (not in jwsdp) output from consolee to catalina.out

    Finally we solve this.
    In startup.bat we've changed string
    call "%EXECUTABLE%" start %CMD_LINE_ARGS%
    to
    call "%EXECUTABLE%" run %CMD_LINE_ARGS% 1>..\logs\catalina.out 2>..\logs\catalina-err.out
    (the above in one string)
    May be someone know something better?

  • How can I run external console program, printing output to JTextPane?

    How can I run external console program, printing output to JTextPane?
    I have a console app. written in C++ and I would like to run in it from java swing app. and I would like to see its output in a JTextPane.

    I have used this article
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    to successfully pipe output from jboss batch files to a JTextPane.

Maybe you are looking for

  • Time Machine Backup error message with iMac.sparsebundle (error 109).

    I get an error that the backup disk image "/volumes, <my name> Time Caps/<my name> iMac.sparsebundle" could not be accessed (error 109). How do I correct this?  Thanks.

  • My matshita uj846 super drive wont burn dvd. get error

    my super drive wont burn dvd . and i get an error : sense key medium error sense code =0x73,0x03 for cd it work fine and read dvd ok just wont burn dvd of any kind tryed differrent makes but no result .. help pls

  • Parse files in directory newer than MM/DD/YYYY

    In the attached VI I am trying to figure out how to pull in and parse all .txt log files in Folder path newer than a particular date instead of just the *.txt (all text files) as it is set to now. The date I will be entering from a sub VI is a string

  • How to register URL Provider

    I have a URL Portlet installed in my Oracle 9i Application Server. Although the URL Portlet is installed, I don't know how to register the URL Portlet. Which page do I need to go to register the Provider I have tried to add a new Provider in Adminste

  • How to find grand total

    Hi experts, I have one internal table containing 2 fields quantity and amount.In the output i want to show total quantity and total amount. How can i achive it..? something like this qty  amt 1     10 2     20 3     30 6     60 reward guaranteed than