aspose file tools*
The moose likes JSP and the fly likes Want jsp to telnet into a computer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Want jsp to telnet into a computer" Watch "Want jsp to telnet into a computer" New topic
Author

Want jsp to telnet into a computer

northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
I want a jsp page to be able to telnt into a computer but do not know how to do it?
My environment is Unix.
I would normally telnet into this computer on a command prompt
$telnet 161.74.69.30
Here is my front jsp page:
<html>
<head>
<title> Login into centre of parallel computing </title>
</head>
<body>
<form action="processLoginToParisal.jsp" method="get">
<br>
Do yo wish to login to Parisfal?
<br>
<input type="submit" name="yes" value=" Yes ">
<input type="submit" name="no" value=" No ">
</form>
</body>
</html>
Once the user clicks "Yes" it telnets into a computer. How am I able to achive this task?
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
Okay is it possible to send commands on the Unix command shell?
I want to basically send commands to Unix shell, so thus the JSP will provide a front portal/interface to Unix command, so that the user does not need to type everything in but press s few buttons???
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
Remember that JSP operate with a request/response that does not remember any state. That is going to complicate things if you have more than one user.
For running programs such as telnet, Java provides the various exec methods in java.lang.Runtime. You can get streams that send/receive data to/from resulting process.
Alternately you could open a socket directly.
I suggest you experiment first with some sort of "bean - like" component, rather than getting tangled up with JSP at the start.
Bill
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
Okay I have written a code to ftp.
But when I run the program I do not know what has happened???
How can I do the next stage like enter "user name" "password" and finally run "ls" command for unix???
import java.lang.*;
import java.io.*;
public class RuntimeFTP{
public static void main(String[] arg){
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = { "ftp.exe", "jaguar.wmin.ac.uk" };
try
{
Process child = rt.exec(callAndArgs);
child.waitFor();
System.out.println("Process exit code is: " + child.exitValue() );
}
catch(IOException e)
{
System.err.println("IOException starting process!");
}
catch(InterruptedException e)
{
System.out.println("Interrupted waiting for process!");
}
}
}
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

William has already answered your question with this:
You can get streams that send/receive data to/from resulting process.

Hope this helps!
Barry
northfield Sid
Ranch Hand

Joined: Aug 08, 2002
Posts: 106
>You can get streams that send/receive data to/from resulting process.
Do you have any examples?
books/urls?
I have looked at feq books but they all cover file stream, I actually used this example for the very simple example given above.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want jsp to telnet into a computer