0% found this document useful (0 votes)
25 views5 pages

Java Remote Command Execution Guide

The document describes a program for remote command execution in Java. It involves creating a server and client that can communicate over a socket. The server accepts connection requests on port 100 and uses buffered readers and writers to send and receive data. Based on the client's command, the server returns the date, time, or an error message. The client sends commands to the server and prints the responses until sending "bye" to terminate the connection.

Uploaded by

Reka T Sambandam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Java Remote Command Execution Guide

The document describes a program for remote command execution in Java. It involves creating a server and client that can communicate over a socket. The server accepts connection requests on port 100 and uses buffered readers and writers to send and receive data. Based on the client's command, the server returns the date, time, or an error message. The client sends commands to the server and prints the responses until sending "bye" to terminate the connection.

Uploaded by

Reka T Sambandam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Title: Remote Command Execution

Aim: To write a program in java for Remote Command Execution. ALGORITHM: Step 1: Start the program Step 2: Create two objects for string class. Step 3: Inside create new Socket([Link](), portno()); Step 4: Using object for buffered reader class gets the client date. Step 5: Using object the printer writer class, prints the client date. Step 6: While the user does not enter bye catch the exception. Step 7: On server side, create an object for the server socket class. Step 7: Establish the connection using accept() method of the socket class. Step 8: Get the client input using buffered reader class object. Step 9: Using conditional loop print system data, time etc based on the user request and else print the user is invalid. Step 10: Run the server and client invoke server method on client side. Step 11: Print out with the necessary details.

REMOTESERVER: import [Link].*; import [Link].*; import [Link].*; class remoteserver { public static void main(String args[])throws Exception { String com=new String(); ServerSocket ss=new ServerSocket(100); Socket s=[Link](); BufferedReader nin=new BufferedReader(new InputStreamReader([Link]())); PrintWriter nout=new PrintWriter([Link](),true); do { com=[Link](); if([Link]("date")) { Calendar c=[Link](); [Link]([Link](Calendar.DAY_OF_MONTH)+","+([Link]([Link]) +","+([Link]([Link])+1)+","+[Link]([Link]))); [Link]("Date is [Link] terminated with client"); } else { if([Link]("time")) { Calendar c=new GregorianCalendar(); [Link](new Date()); [Link]([Link]([Link])+","+([Link]([Link]) +1)+","+[Link]([Link])); [Link]("Time is [Link] terminated with client"); } else { [Link]("your request is invalid"); [Link]("Proper response is sent to your client"); } } } while(![Link]("bye")); [Link]("connection terminated with client");

} } REMOTECLIENT2: import [Link].*; import [Link].*; class remoteclient2 { public static void main(String args[])throws IOException { String rec=new String(); String res=new String(); try { Socket s=new Socket([Link](),100); BufferedReader cin=new BufferedReader(new InputStreamReader([Link])); BufferedReader sin=new BufferedReader(new InputStreamReader([Link]())); PrintWriter nout=new PrintWriter([Link](),true); do { rec=[Link](); [Link](rec); res=[Link](); [Link](res); } while([Link]("bye")); } catch(Exception e) { [Link]("error:"+e); } } }

OUTPUT:

RESULT: Thus, the Remote Command Execution has been implemented successfully.

You might also like