Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geclipse-dev] Publish ssh tool

Hi Romain

I had to change the interface a little (in the head now and will be in the nightly build tonight):
SSHPersistantConnection.connect() throws ProblemException
 
Below is a little code snipped using the SSHPersistantConnection class. There are some problems in that some strange characters are returned. I believe that they are formating codes as this is a terminal connection. Hopefully you can use this temporarily until the Connection Framework has been developed.  

Please let me know if you have any questions. 


======
public synchronized boolean remoteSession( final ISSHConnectionInfo sshConnectionInfo ) {

    char[] buffer = new char[ 100 ];
    String result = ""; //$NON-NLS-1$
    String errResult = ""; //$NON-NLS-1$
    SSHPersistantConnection con = new SSHPersistantConnection();
    con.createSession( sshConnectionInfo, null );

    if ( con.isSessionActive() ) {
      con.connect( );

      try {
        BufferedWriter stdoutWriter = new BufferedWriter( new OutputStreamWriter( con.getOutputStream() ) );
        BufferedReader stdoutReader = new BufferedReader( new InputStreamReader( con.getInputStream() ) );
        BufferedReader stderrReader = new BufferedReader( new InputStreamReader( con.getErrorStream() ) );

    

        stdoutWriter.write( "ls\n" );
        stdoutWriter.flush();

        // Might not be needed
        try {
          Thread.sleep( 1000 );
        } catch (InterruptedException e) {
          // Ignor for now
        }

        int read = 0;
        while ( stdoutReader.ready() && read != -1 ) {
          read = stdoutReader.read( buffer, 0, 100 );
          result = result + new String(buffer);
        }

        read = 0;
        while ( stderrReader.ready() && read != -1 ) {
          read = stderrReader.read( buffer, 0, 100 );
          errResult = errResult + new String(buffer);
        }        
      } catch (IOException e) {
        // Ignor for now
      }
    }
    System.out.println( "outPut:\n" + result );
    System.out.println( "error:\n" + errResult );

}

=====

Best Regards,
Harald Gjermundrod




On Aug 28, 2008, at 11:57 AM, Romain wrote:

Hi Harald,

thank you, it seems great, I am trying it right now to implement the pbs job service.
I haven't understand so how it is possible to exec commands, get the return codes.

Cheers,
Rom



Harald Gjermundrod a écrit :
Hi Romain

I have added the following class: SSHPersistantConnection.java in the eu.geclipse.batch

In order to use it you first call:
createSession( final ISSHConnectionInfo sshConnectionInfo,
                            final List<IForward> forwards ) throws ProblemException
then
connect( final InputStream inStream, final OutputStream outStream ) throws ProblemException


I tried a quick test but didn't get anything back. But it may have been my test that didn't work. Please try it out and see if it works for you. I will work on it more next week.
Thanks,
Harald Gjermundrod
harald@xxxxxxxxxxxx <mailto:harald@xxxxxxxxxxxx>




On Jul 18, 2008, at 3:27 PM, Romain wrote:

Harald Gjermundrod a écrit :
Dear Romain

The SSHConnection class is now exposed in the Head version. Please let us know if you need anything else.
Thank you.

I need to read the standard output and write on the standard input of a process launched through the ssh connection is it possible to have several prototypes like allowing to give input and out streams for stdin, stdout, stderr. For exemple

The prototype

public String execCommand( final String command, InputStream stdin ) throws ProblemException

The use:

InputStream in = new ByteArrayInputStream(builder.toString().getBytes());
String result = connection.execCommand("qsub", in);


Best regards, Romain

Best Regards,
Harald G.



On Jul 18, 2008, at 12:29 PM, Romain wrote:

Hi guys,

I have started to develop a PBS plugin for g-Eclipse. I need to access the PBS cluster through a SSH connection.
Is it possible change the SSHConnection class for being visible outside the eu.geclipse.batch bundle?

Best Reagards,
Romain.
_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx <mailto:geclipse-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/geclipse-dev

_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx <mailto:geclipse-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/geclipse-dev

_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx <mailto:geclipse-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/geclipse-dev

------------------------------------------------------------------------

_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev
 

_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev


Back to the top