public boolean setEnvironmentVariable ( String name , String value ) throws SshException { ByteArrayWriter request = new ByteArrayWriter ( ) ; try { request . writeString ( name ) ; request . writeString ( value ) ; return sendRequest ( "env" , true , request . toByteArray ( ) ) ; } catch ( IOException ex ) { throw new SshException ( ex , SshException . INTERNAL_ERROR ) ; } finally { try { request . close ( ) ; } catch ( IOException e ) { } } }
The SSH2 session supports the setting of environments variables however in our experiance no server to date allows unconditional setting of variables . This method should be called before the command is started .