From a servlet running in IIS under Windows, is it possible to kick off an rsh command to run a script on a remote UNIX machine?
Created May 4, 2012
Vincent Cirel Just off the top of my head, the following (pseudo code) is how I'd stab at it;
should point in the right direction anyway. If you want a response you'll need to create the corresponding DataInputStream.
Hope this helps.
Vincent
This assumes you have rsh set up on the host and you send an appropriate username with the command if required.
import java.net.*
//create a Socket object connected to port 514 (shell/cmd port used by rsh)
Socket mySock = new Socket("destination host",514);
//get the output stream for the socket
DataOutputStream outStream;
outStream = new DataOutputStream(mySock.getOutputStream());
//construct the command string
String rshStr = "whatever command you want to send"
//send it on its way
outStream.writeBytes(rshStr);
outStream.write(13);
outStream.write(10);
outStream.flush();
Hope this helps.
Vincent