How to redirect i/o

I have a gui that was originally designed just to print information to the screen that would normally be displayed in a normal CMD or Cygwin window. However, I now need to be able to provide input just like on the cmd line. For example, the code is running along and needs a password inorder to connect to a server so it prompts the user to type in the password. How can I capture this input and use it?
    private void runProcess() throws Exception {
        File workDir = new File("C:/cygwin/bin"); //"D:/BFAPPS/cygwin/bin");
        String[] cmdArray = new String[5];
        cmdArray[0] = "C:/cygwin/bin/bash"; //"D:/BFAPPS/cygwin/bin/bash";
        cmdArray[1] = "--login";
        cmdArray[2] = "-i";
        cmdArray[3] = "-c";
        cmdArray[4] = "cd " + build_path + "/deploy/scripts/deploymentscript" + " ;ant -f Deployment.xml all";
        for (int i = 0; i < cmdArray.length; i++){
            System.out.println(cmdArray);
Process p = Runtime.getRuntime().exec(cmdArray, null, workDir);
StreamPumper out = new StreamPumper(new InputStreamReader(p.getInputStream()), new OutputStreamWriter(System.out));
StreamPumper err = new StreamPumper(new InputStreamReader(p.getErrorStream()), new OutputStreamWriter(System.err));
StreamPumper in = new StreamPumper(new InputStreamReader(System.in), new OutputStreamWriter(p.getOutputStream()));
out.start();
in.start();
err.start();
p.waitFor();
out.join();
in.join();
err.join();
button3.setEnabled(true);
class StreamPumper extends Thread {
String line;
InputStreamReader input;
OutputStreamWriter output;
BufferedReader buffer;
BufferedWriter bw;
StreamPumper(InputStreamReader input, OutputStreamWriter output) {
this.input = input;
this.output = output;
buffer = new BufferedReader(input);
bw = new BufferedWriter(output);
setDaemon(true);
public void run() {
try {
while ((line = buffer.readLine()) != null) {
textArea1.append(line + "\n");
textArea1.setCaretPosition(textArea1.getDocument().getLength()); //I need to be able to 'read' input
          try {
Thread.sleep(50);
} catch(Exception e) {
e.printStackTrace(System.err);
}catch(IOException ioe) {
ioe.printStackTrace(System.err);
System.exit(1);

Read the following:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
It is full of information about the Runtime.exec and its varying effects and effectiveness.

Similar Messages

  • How to redirect to different page after login in APEX 4.1

    Dear All,
    Here my Requirement is,When the users login,
    when they entered their username and password and pressed login button,
    they have to redirected to different pages based on the type of user.
    Here my LOGIN_TABLE has following 3 columns,
    1.Username
    2.Password
    3.Type.
    The TYPE has 2 values, employee and admin.
    when the type is admin they should be redirected to page 2,
    reaining i.e employee users has to be redirected to page 3.
    How can I do this? please give some suggestion.
    Thank you.
    regards,
    Gurujothi

    Dear Christian,
    Thank you for your reply,
    I would like to explain something,
    When I using the following function,
    *create or replace FUNCTION custom_auth_g (
    p_username IN VARCHAR2,
    p_password IN VARCHAR2)
    RETURN BOOLEAN IS
    BEGIN
    FOR c1 IN (SELECT 1
    FROM login_table
    WHERE upper(username) = upper(p_username)
    AND upper(password) = upper(p_password))
    LOOP
    RETURN TRUE;
    END LOOP;
    RETURN FALSE;
    END;*
    When login, It checks in the login_table table and if the username is exist with the pass word it successfully entered inside the application.
    for all users only one page which we set.
    My Login_table also contains type which has 2 type as I mentined above.
    But As I mentioned earliar based on the user type it has to be redirected to 2 different page.
    I found this Package but I cant understand,Can you please Explain?
    *create or replace PACKAGE app_security_pkg
    AS
    PROCEDURE add_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    PROCEDURE login
    p_uname IN VARCHAR2
    ,p_password IN VARCHAR2
    ,p_session_id IN VARCHAR2
    ,p_flow_page IN VARCHAR2
    FUNCTION get_hash
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    RETURN VARCHAR2;
    PROCEDURE valid_user2
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    FUNCTION valid_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    RETURN BOOLEAN;
    END app_security_pkg;*
    *create or replace PACKAGE BODY app_security_pkg
    AS
    PROCEDURE login
    p_uname IN VARCHAR2
    ,p_password IN VARCHAR2
    ,p_session_id IN VARCHAR2
    ,p_flow_page IN VARCHAR2
    IS
    lv_goto_page NUMBER DEFAULT 1;
    BEGIN
    -- This logic is a demonstration of how to redirect
    -- to different pages depending on who successfully
    -- authenticates. In my example, it simply demonstrates
    -- the ADMIN user going to page 1 and all other users going
    -- to page 2. Add you own logic here to detrmin which page
    -- a user should be directed to post authentication.
    IF UPPER(p_uname) = 'ADMIN'
    THEN
    lv_goto_page := 1;
    ELSE
    lv_goto_page := 2;
    END IF;
    APEX_UTIL.SET_SESSION_STATE('FSP_AFTER_LOGIN_URL');
    wwv_flow_custom_auth_std.login
    p_uname => p_uname,
    p_password => p_password,
    p_session_id => p_session_id,
    p_flow_page => p_flow_page || ':' || lv_goto_page
    EXCEPTION
    WHEN OTHERS
    THEN
    RAISE;
    END login;
    PROCEDURE add_user
    p_username IN VARCHAR2
    ,p_password IN VARCHAR2
    AS
    BEGIN
    INSERT INTO app_users (username, PASSWORD)
    VALUES (UPPER (p_username),
    get_hash (TRIM (p_username), p_password));
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    ROLLBACK;
    RAISE;
    END add_user;
    -- Function to Perform a oneway hash of the users
    -- passwords. This cannot be reversed. This exmaple
    -- is a very week hash and if been used on a production
    -- system, you may want to use a stronger hash algorithm.
    -- Read the Documentation for more info on DBMS_CRYPTO as
    -- this is the supported package from Oracle and
    -- DBMS_OBFUSCATION_TOOLKIT is now depricated.
    FUNCTION get_hash (p_username IN VARCHAR2, p_password IN VARCHAR2)
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN DBMS_OBFUSCATION_TOOLKIT.md5 (
    input_string => UPPER (p_username)
    || '/'
    || UPPER (p_password));
    END get_hash;
    PROCEDURE valid_user2 (p_username IN VARCHAR2, p_password IN VARCHAR2)
    AS
    v_dummy VARCHAR2 (1);
    BEGIN
    SELECT '1'
    INTO v_dummy
    FROM app_users
    WHERE UPPER (username) = UPPER (p_username)
    AND PASSWORD = get_hash (p_username, p_password);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN raise_application_error (-20000, 'Invalid username / password.');
    END valid_user2;
    FUNCTION valid_user (p_username IN VARCHAR2, p_password IN VARCHAR2)
    RETURN BOOLEAN
    AS
    BEGIN
    valid_user2 (UPPER (p_username), p_password);
    RETURN TRUE;
    EXCEPTION
    WHEN OTHERS
    THEN RETURN FALSE;
    END valid_user;
    END app_security_pkg;*
    And you said "assign an URL to FSP_AFTER_LOGIN_URL, depending on the Type column",
    Where to assign,Could you please Explain?
    Thank you.

  • How to display swf in full screen mode and how to redirect to a url

    Hi,
    I have 2 questions :
    Question 1 - I have a flash swf file and I want to display it in the browser in full mode meaning it should fit the browser, I have tried adding
    fscommand("fullscreen", "true");
    in the first frame of a lyaer but it does not work.
    Question 2 - How to redirect to another page at the end of the swf movie, I have tried adding :
    stop(); 
    navigateToURL( new URLRequest("*www.microsoft.com*"), "_self");
    in the last frame but it does not work.
    Thank you very very much for your assitance !!
    Terry

    "fscommand("fullscreen", "true");" only works for self-running executables, not embedded SWFs in a web page.
    To get the swf to fill the browser page, the best thing to do would be to adjust the publish settings of the "HTML Wrapper" page and copy the necessary pieces from the resultant HTML file into the HTML file you are putting the swf into.
    I have had some successes dealing with similar navigation issues by breaking up the code into multiple tasks:
    var url:String = "http://www.microsoft.com";
    var urlReq:URLRequest = new URLRequest(url);
    navigateToURL(urlReq);
    I can't guarantee that will help, but at least I tried.  :-)

  • How to redirect to other page in a dialogListener?

    Hi All,
    I am using JDeveloper 11g with ADF BC.
    How to redirect to another page from a dialogListener of <af:dialog>?
    I have a page with a [Delete] button on it. When user click on the delete button, a confirmation dialog will appear to ask "Are you sure? [Yes/No]". If user answer [Yes], I will delete the current record, and go to another page. I can call a Operation Binding in the dialogListener, but I don't know how to go to another page.
    public void handleDeleteDialog(DialogEvent dialogEvent) {
    OperationBinding operationBinding = bindings.getOperationBinding("Delete");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    // redirect to another page?
    Regards,
    Samson Fu

    Hi Samson,
    Check following link for your query:-
    Re: page has to navigate to the next page when  clicking button in the popup
    You can also make usae of Navigation Handler to invoke the navigation action in your task flow as
    FacesContext facesCtx = FacesContext.getCurrentInstance();
    NavigationHandler nh = facesCtx.getApplication().getNavigationHandler();
    nh.handleNavigation(facesCtx, "", "ActionNameInTaskFlow");
    Vikram

  • How to redirect users to Custom Page on InfoView logoff

    Post Author: Srinivas123
    CA Forum: WebIntelligence Reporting
    How to redirect the users on InfoView logoff to a custom page, instead of the default logon.aspx.   

    Hello Senana,
    Assuming you're using wwv_flow_custom_auth_std.login to log in, and p_flow_page is set to "[your app id]:1" try placing the following line just before your call to wwv_flow_custom_auth_std.login:
    :FSP_AFTER_LOGIN_URL := null;This should force user to page 1 after log-in.
    Hope this helps,
    John

  • How to redirect a JSP page after the session is killed

    Hello!
    I am quite new to JSP. I have a question about how to redirect a jsp page after the session is killed. Could anyone help?
    thanks a lot in advance!

    You can't, directly. There's no connection betweenthe server and browser.
    even after invalidating the session. we can do it
    directly using the statement
    response.sendRedirect("....");
    or we can use the meta refresh tag.if session is invalidated and if we try to do response.sendRedirect(".. ") it throws IllegalStateException

  • How to redirect a page to a new window instead of the current one

    Can someone please tell me how to redirect a page to new window.
    I mean I am running a JSP with a button and on clicking it i am opening a new window (thru javascript offcourse),
    Now response.sendirect("New.jsp") should be opened in that new window opened.
    I tried it but the New.jsp page is opened in the current page (Even though new window is opened ! ).
    Please help.

    Hi,
    U can use the following code to Pop up in new window
    Jsp1.jsp
    <%
    if(action != "")
    response .sendRedirect("Jsp2.jsp");
    else
    %>
    <html><head><title>JSP 1</title>
    <script language="JavaScript">
    function View()
    window.open("Jsp1.jsp?action=view","View","");
    </script>
    </head><body>
    <form name="frm" method="post">
    <input type="button" value="View" onclick="View()">
    </form>
    </body>
    </html>
    <%

  • Need a site for how to redirect if session is empty

    I have a session that i have created as soon as someone
    logins. I need some
    help on how to redirect the person if they try to access a
    page without the
    session.
    i have 5 pages... based on your login you entered, i am
    keeping that name in
    the session... on each page i have a stored procedure that is
    executed on
    submit to verify that name against the table to add the recid
    into the new
    table..
    I want to make sure that on page load if that session is
    empty then redirect
    to main page to login and continue

    thanks for the reply... cant tell you if it works, im working
    on ASP that
    was my fault for not stating it...
    Building the app in ASP, SQL2005 using DW8
    "geschenk" <[email protected]> wrote in
    message
    news:f0tasq$oho$[email protected]..
    > You´ll probably just need to paste the following
    snippet *at the very
    > beginning*
    (line 1) of the respective page:
    >
    > <?php
    > if(!isset($_SESSION['username'])) { // if session
    variable "username"
    > doesn´t
    > exist or has expired...
    > header('Location: login.php'); // ...redirect to the
    login page
    > }
    > ?>
    >
    > I *think* this should work
    >

  • How to redirect loading flow in process chain based on logic?

    Hi Experts,
    I have a scenario where I want to keep data for last 3 years in 3 different cubes.e.g. lets say cube 1 holds data for current 2006 year, cube 2 holds 2005 and cube 3 holds 2004.Now in next year 2007, I want to keep data for 2007, 2006 and 2005.I want to keep data for 2007 in cube 3 which was holding 2004 data.(delete 2004 data and load 2007).
    This process should be automated i.e. which cube to load should be done auto.In short, <b>data for new cube should go into cube which is holding data for oldest year.</b>
    I want to know :
    1) Which Options I can use to do this?
    2) What about ABAP program : custom table can be maintained to know which cube is holding what data, but how to redirect loading flow?
    3) What about "Decision process type" in process chain?
    4) Also would custom process type solve this functionality?
    Any ideas would be highly appreciated.
    Thanks in advance,
    Sorabh

    Hi Sorabh,
    Its just an Idea, Im assuming that this would work. This should also work for INIT DELTA I guess. But would need proper testing.
    Have a Custom Table ZCUBEYEAR and maintain the CUBE as the Key.
    ZCUBEYEAR
    CUBE     YEAR
    Y1       2004
    Y2       2005
    Y3       2006.
    In the update rule->Start Routine for Cube Y1, extract this entry from the table ZCUBEYEAR for Y1, which in this case would be 2004.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY1.
    in our case YEARFORCUBEY1 = 2004.
    For cube Y2 and Y3 the Delete statement would be as follows in their Start Routines.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY2.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY3.
    This would ensure that only 2004 data would flow to Y1, 2005 for Y2 and 2006 for Y3.
    Once we come to a NEW YEAR, We need to run a program or Manually change the CUSTOM TABLE "ZCUBEYEAR" updating the cube Y1 with 2007, the Deltas would flow correctly.
    Please email me at [email protected], we could have a detailed discussion.
    Hope the above helps your cause.
    Regards,
    Praveen.

  • How to redirect user from login page to "Set Challenge question" page

    How to redirect user from login page to "Set Challenge question" page (NOT custom page) after 3 un successful password attempts?
    Meaning when user types wrong password 3 times they will be redirected to set Challenge question page. If user answers the challenge question then password reset page should be appeared other wise (after remaining 3 un successeful challenge question answers) account should be locked out.
    thanks for your help.

    hi sandeep
    Thanks for your answer. Let me ellaborate more on the requirement here.
    - Password Policy and Lost Password management are set up in the identity system
    - Configure login tries allowed= 5. Verify accout is lock out after 5 unsucessful login.
    This is what need to achieve.
    1) If a user attempts to login 3(not 5) times using an incorrect login credential he/she should be redirected to set challenge question (security question) page.
    2) Then if the user attempts (remaining) 2 times incorrect challenge answer then his/her account should be locked out.
    3) If he/she answers the challenge answer correctly then he/she should be redirected to password reset page.
    Is this possible?

  • 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 in java code not the jsp or any other

    hello
    can any one help me how to redirect in java pages the code must be in java function not in jsp or any thing else
    thanks in advance

    Function? Don't you rather mean method?
    Anyway, in JSF you can send a redirect using ExternalContext#redirect(). If your JSF environment is on top of JSP/Servlet, then under the hood it basically invokes HttpServletResponse#sendRedirect() and FacesContext#responseComplete().

  • 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 to redirect on htttp to https with www redirect of coldfusion mx7?

    Hi any one help me  - How to redirect on htttp to https with www redirect of coldfusion mx7?

    I used below code. its working perfectly. thanks a lot. 
    <cfif (CGI.SERVER_NAME EQ "site.com") and (CGI.https NEQ "on")>
    <cfheader statuscode="301" statustext="Moved permanently">
    <cfheader name="Location" value="https://www.site.com#CGI.SCRIPT_NAME#">
    </cfif>
    <cfif (CGI.SERVER_NAME EQ "www.site.com") and (CGI.https NEQ "on")>
    <cfheader statuscode="301" statustext="Moved permanently">
    <cfheader name="Location" value="https://www.site.com#CGI.SCRIPT_NAME#">
    </cfif>
    <cfif CGI.SERVER_NAME EQ "site.com">
    <cfheader statuscode="301" statustext="Moved permanently">
    <cfheader name="Location" value="http://www.site.com#CGI.SCRIPT_NAME#">
    </cfif>

  • SAP EP - How to redirect in case of a reqest for a non-existent portal pag

    Hello,
    I am not 100% sure if this is the right forum to ask my question but I will give it a try anyway.
    I would like to customize the error handling of the SAP EP 6.0 in the following way. If a user tries to access a page of the portal that does not exist, the user should receive an error page describing the problem occured and should be redirected to the homepage after a short period of time.
    In a portal environment with default configuration the user would immediately be redirected to the homepage. There is no error message displayed.
    Does anyone know where to start digging? I think I need a better understanding of SAP EP error handling. I appreciate all answers, hints and suggestions.
    Cheers
    Martin
    Message was edited by: Martin Kellermann
    Message was edited by: Martin Kellermann

    Hi guys,
    I am sorry to start discussion on that topic again. But I definitely need some help. Due to Samuli's help I have been able to modify the error handling of the portal in the following way.
    <b>Customization:</b>
    User attempts to access a wrong url within the portal (e.g. http://<portal_server>:50000irjportalwrongurl). Instead of the standard "404 the requested resource is not available" error page I see my own error page. That's nice.
    <b>What did I do:</b>
    I added the following lines to the portal's web.xml (/usr/sap/J2E/JC00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-infweb.xml):
    <error-page>
      <error-code>404</error-code>
      <location>/customerrors/404.html</location>
    </error-page>
    Additionally, I created a the 404.html file and put it in folder (/usr/sap/J2E/JC00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/customerrors/.
    <b>What else?</b>
    Well, I am using KM to make files accessible through the EP platform. If I access a KM file via the portal (http://<portal_server>:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/Public%20Documents/Testfile.txt)an extra window opens and shows me the content of the file. In case I enter a wrong url (e.g. http://<portal_server>:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/Public%20Documents/wrong_file_name.txt)I see the standard "404 The requested resource is not available" error page. But I want to see my customized error page.
    <b>How to</b>
    I think I have to modify the web.xml of the KM the same way I did for the portal. But I do not know where to find the KM web.xml? Please could someone advise me where to look?
    I appreciate all kinds of help!
    Martin

Maybe you are looking for

  • How to reference v$database in a package

    How do you reference the view v$database in a package? CREATE OR REPLACE package body temp as dbname varchar2(10); procedure temp_proc is begin select name into dbname from v$database; end; end; Says table or view does not exist when I try to compile

  • The audio file can not be changed! - help

    I really need help. I just installed Logic Express 8, and I tried to import a song in order to edit it (as a lead in music bed for a podcast). Every song I import in says I am unable to edit it - "The audio file can not be changed! Volume or file is

  • ODBC Issues with SAP Predictive Analytics 2.0 - Automated Analysis

    Dear all, maybe this adds only an aspect to the Infinite Insight OCBC Connection difficulties discussed in http://scn.sap.com/message/15766247#15766247 but after trying and searching the web for more than a day any help would be appreciated. This is

  • I think someone stole my ipod.. What do I do to find it? I looked everywhere.

    HELPPPP!

  • Splash element in JNLP

    Hi, I was experimenting with getting the splash gif/jpg file from another server. So rather than: <icon kind="splash" href="linedup.jpg"/> which refers to a local .jpg file I put in the following: <icon kind="splash" href="http://theirsite.com/images