commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "StompDagger1@yahoo.com" <stompdagg...@yahoo.com>
Subject org.apache.commons.net.bsd.RLoginClient doesn't flush output
Date Tue, 21 Dec 2010 17:39:02 GMT
hello, I have a java program which connects to a unix account and needs to run 
some local scripts, the code looks like this:
        RLoginClient connection=new RLoginClient();
        String lUser=System.getProperty("user.name"),lHost;
        try {
            lHost=InetAddress.getLocalHost().getHostName();
            RExecClient rExecClient=new RExecClient();
            rExecClient.connect(this.mHost);
            rExecClient.rexec(this.mUser,this.mPasswd,"if [ -f 
"+'"'+".rhosts"+'"'+" ]; then cp .rhosts .rhosts.bak; fi; echo "+'\"'+lHost+" 
"+lUser+"\n"+lHost+".amdocs.com "+lUser+"\n"+lHost+".corp.amdocs.com 
"+lUser+'"'+" >> ~/.rhosts");
            rExecClient.disconnect();
            connection.connect(this.mHost);
            connection.rlogin(lUser,this.mUser,"xterm");
        }
        catch (SocketException e) {
            ...
        }
        catch (IOException e) {
            try {
                connection.disconnect();
            }
            catch (IOException f) {
            ...
        }
        OutputStreamWriter virtualKeyboard=new 
OutputStreamWriter(connection.getOutputStream());
        InputStreamReader virtualScreen=new 
InputStreamReader(connection.getInputStream());
        try {
            virtualKeyboard.write("if [ ! -d installer ]; then mkdir installer; 
chmod 755 installer; fi;".toCharArray());
            virtualKeyboard.flush();

the first rexec works and the command gets executed, but the two last lines get 
executed but on the unix side, I cannot see the output e.g. the folder, copying 
the line as is and running it in unix works.
this leads me to believe that the buffer doesn't get flushed.
how can I fix this?
I'm using latest jars from site and java 1.6 update 14.

thanks.


 
: "    ,               ".


An wise Scandinavian old man once said: "in the end, everything is going to be 
alright"



      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message