Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Want jsp to telnet into a computer

 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic