Java Doc for RExecClient.java in  » Net » Apache-commons-net-1.4.1 » org » apache » commons » net » bsd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache commons net 1.4.1 » org.apache.commons.net.bsd 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.net.SocketClient
      org.apache.commons.net.bsd.RExecClient

All known Subclasses:   org.apache.commons.net.bsd.RCommandClient,
RExecClient
public class RExecClient extends SocketClient (Code)
RExecClient implements the rexec() facility that first appeared in 4.2BSD Unix. This class will probably only be of use for connecting to Unix systems and only when the rexecd daemon is configured to run, which is a rarity these days because of the security risks involved. However, rexec() can be very useful for performing administrative tasks on a network behind a firewall.

As with virtually all of the client classes in org.apache.commons.net, this class derives from SocketClient, inheriting its connection methods. The way to use RExecClient is to first connect to the server, call the RExecClient.rexec rexec() method, and then fetch the connection's input, output, and optionally error streams. Interaction with the remote command is controlled entirely through the I/O streams. Once you have finished processing the streams, you should invoke RExecClient.disconnect disconnect() to clean up properly.

By default the standard output and standard error streams of the remote process are transmitted over the same connection, readable from the input stream returned by RExecClient.getInputStream getInputStream() . However, it is possible to tell the rexecd daemon to return the standard error stream over a separate connection, readable from the input stream returned by RExecClient.getErrorStream getErrorStream() . You can specify that a separate connection should be created for standard error by setting the boolean separateErrorStream parameter of RExecClient.rexec rexec() to true . The standard input of the remote process can be written to through the output stream returned by RExecClient.getOutputStream getOutputSream() .


author:
   Daniel F. Savarese
See Also:   SocketClient
See Also:   RCommandClient
See Also:   RLoginClient



Field Summary
final public static  intDEFAULT_PORT
     The default rexec port.
protected  InputStream_errorStream_
     If a separate error stream is requested, _errorStream_ will point to an InputStream from which the standard error of the remote process can be read (after a call to rexec()).

Constructor Summary
public  RExecClient()
     The default RExecClient constructor.

Method Summary
 InputStream_createErrorStream()
    
public  voiddisconnect()
     Disconnects from the server, closing all associated open sockets and streams.
public  InputStreamgetErrorStream()
     Returns the InputStream from which the standard error of the remote process can be read if a separate error stream is requested from the server.
public  InputStreamgetInputStream()
     Returns the InputStream from which the standard outputof the remote process can be read.
public  OutputStreamgetOutputStream()
     Returns the OutputStream through which the standard input of the remote process can be written.
final public  booleanisRemoteVerificationEnabled()
     Return whether or not verification of the remote host providing a separate error stream is enabled.
public  voidrexec(String username, String password, String command, boolean separateErrorStream)
     Remotely executes a command through the rexecd daemon on the server to which the RExecClient is connected.
public  voidrexec(String username, String password, String command)
    
final public  voidsetRemoteVerificationEnabled(boolean enable)
     Enable or disable verification that the remote host connecting to create a separate error stream is the same as the host to which the standard out stream is connected.

Field Detail
DEFAULT_PORT
final public static int DEFAULT_PORT(Code)
The default rexec port. Set to 512 in BSD Unix.



_errorStream_
protected InputStream _errorStream_(Code)
If a separate error stream is requested, _errorStream_ will point to an InputStream from which the standard error of the remote process can be read (after a call to rexec()). Otherwise, _errorStream_ will be null.




Constructor Detail
RExecClient
public RExecClient()(Code)
The default RExecClient constructor. Initializes the default port to DEFAULT_PORT .




Method Detail
_createErrorStream
InputStream _createErrorStream() throws IOException(Code)



disconnect
public void disconnect() throws IOException(Code)
Disconnects from the server, closing all associated open sockets and streams.


exception:
  IOException - If there an error occurs while disconnecting.




getErrorStream
public InputStream getErrorStream()(Code)
Returns the InputStream from which the standard error of the remote process can be read if a separate error stream is requested from the server. Otherwise, null will be returned. The error stream will only be set after a successful rexec() invocation.

The InputStream from which the standard error of the remoteprocess can be read if a separate error stream is requested fromthe server. Otherwise, null will be returned.




getInputStream
public InputStream getInputStream()(Code)
Returns the InputStream from which the standard outputof the remote process can be read. The input stream will only be set after a successful rexec() invocation.

The InputStream from which the standard output of the remoteprocess can be read.




getOutputStream
public OutputStream getOutputStream()(Code)
Returns the OutputStream through which the standard input of the remote process can be written. The output stream will only be set after a successful rexec() invocation.

The OutputStream through which the standard input of the remoteprocess can be written.




isRemoteVerificationEnabled
final public boolean isRemoteVerificationEnabled()(Code)
Return whether or not verification of the remote host providing a separate error stream is enabled. The default behavior is for verification to be enabled.

True if verification is enabled, false if not.




rexec
public void rexec(String username, String password, String command, boolean separateErrorStream) throws IOException(Code)
Remotely executes a command through the rexecd daemon on the server to which the RExecClient is connected. After calling this method, you may interact with the remote process through its standard input, output, and error streams. You will typically be able to detect the termination of the remote process after reaching end of file on its standard output (accessible through RExecClient.getInputStream getInputStream() . Disconnecting from the server or closing the process streams before reaching end of file will not necessarily terminate the remote process.

If a separate error stream is requested, the remote server will connect to a local socket opened by RExecClient, providing an independent stream through which standard error will be transmitted. RExecClient will do a simple security check when it accepts a connection for this error stream. If the connection does not originate from the remote server, an IOException will be thrown. This serves as a simple protection against possible hijacking of the error stream by an attacker monitoring the rexec() negotiation. You may disable this behavior with RExecClient.setRemoteVerificationEnabled setRemoteVerificationEnabled() .


Parameters:
  username - The account name on the server through which to executethe command.
Parameters:
  password - The plain text password of the user account.
Parameters:
  command - The command, including any arguments, to execute.
Parameters:
  separateErrorStream - True if you would like the standard errorto be transmitted through a different stream than standard output.False if not.
exception:
  IOException - If the rexec() attempt fails. The exceptionwill contain a message indicating the nature of the failure.




rexec
public void rexec(String username, String password, String command) throws IOException(Code)
Same as rexec(username, password, command, false);



setRemoteVerificationEnabled
final public void setRemoteVerificationEnabled(boolean enable)(Code)
Enable or disable verification that the remote host connecting to create a separate error stream is the same as the host to which the standard out stream is connected. The default is for verification to be enabled. You may set this value at any time, whether the client is currently connected or not.


Parameters:
  enable - True to enable verification, false to disable verification.




Fields inherited from org.apache.commons.net.SocketClient
final public static String NETASCII_EOL(Code)(Java Doc)
protected int _defaultPort_(Code)(Java Doc)
protected InputStream _input_(Code)(Java Doc)
protected boolean _isConnected_(Code)(Java Doc)
protected OutputStream _output_(Code)(Java Doc)
protected SocketFactory _socketFactory_(Code)(Java Doc)
protected Socket _socket_(Code)(Java Doc)
protected int _timeout_(Code)(Java Doc)

Methods inherited from org.apache.commons.net.SocketClient
protected void _connectAction_() throws IOException(Code)(Java Doc)
public void connect(InetAddress host, int port) throws SocketException, IOException(Code)(Java Doc)
public void connect(String hostname, int port) throws SocketException, IOException(Code)(Java Doc)
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException(Code)(Java Doc)
public void connect(String hostname, int port, InetAddress localAddr, int localPort) throws SocketException, IOException(Code)(Java Doc)
public void connect(InetAddress host) throws SocketException, IOException(Code)(Java Doc)
public void connect(String hostname) throws SocketException, IOException(Code)(Java Doc)
public void disconnect() throws IOException(Code)(Java Doc)
public int getDefaultPort()(Code)(Java Doc)
public int getDefaultTimeout()(Code)(Java Doc)
public InetAddress getLocalAddress()(Code)(Java Doc)
public int getLocalPort()(Code)(Java Doc)
public InetAddress getRemoteAddress()(Code)(Java Doc)
public int getRemotePort()(Code)(Java Doc)
public int getSoLinger() throws SocketException(Code)(Java Doc)
public int getSoTimeout() throws SocketException(Code)(Java Doc)
public boolean getTcpNoDelay() throws SocketException(Code)(Java Doc)
public boolean isConnected()(Code)(Java Doc)
public void setDefaultPort(int port)(Code)(Java Doc)
public void setDefaultTimeout(int timeout)(Code)(Java Doc)
public void setSoLinger(boolean on, int val) throws SocketException(Code)(Java Doc)
public void setSoTimeout(int timeout) throws SocketException(Code)(Java Doc)
public void setSocketFactory(SocketFactory factory)(Code)(Java Doc)
public void setTcpNoDelay(boolean on) throws SocketException(Code)(Java Doc)
public boolean verifyRemote(Socket socket)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.