473,699 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Telnet JAVA

4 New Member
Hey guys, im working on a project that requires a telnet connection to be made from a web page to a router, auto login then quit/drop whatever, its just gotta run one and in the background. my friend wrote me this code because i know nothing about java but i cant even begin to imagine how to make this thing run.
Ive tried useing html tags like inserting a java applet but this seems not to work.
I know it would be much more respectable to sit down and learn java, but i am really baffled at what i have read and dont really have the time, i just need this code to be executable from a web page,
Can someone please direct me to a solution :(
This is what i have,
thisfile.class
thisfile.jar
thisfile.java <---(this is the text in this file)
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.net.*;
  3.  
  4. public class TelnetClient {
  5.  
  6.     /**
  7.      * @param args - host, port, username, password
  8.      */
  9.     public static void main(String[] args) 
  10.     {
  11.         //System.out.println("Starting");
  12.         //System.out.println(args[0] + " " + args[1] + " " + args[2] + " " + args[3]);
  13.         new TelnetClient(args[0], args[1], args[2], args[3]);
  14.     }
  15.  
  16.     public TelnetClient(String host, String port, String username, String password)
  17.     {
  18.         //System.out.println(host + " " +port + " " + username + " " + password);
  19.         try
  20.         {
  21.             int intPort = Integer.parseInt(port);
  22.             Socket telnet = new Socket(host, intPort);
  23.  
  24.             //System.out.println(intPort + " " + " " + telnet.getRemoteSocketAddress() + " " + telnet.isConnected());
  25.  
  26.             PrintWriter telnetOut = new PrintWriter(telnet.getOutputStream());
  27.             telnetOut.println(username);
  28.             telnetOut.println(password);
  29.             String exit = "quit";
  30.             telnetOut.println(exit);
  31.             telnetOut.flush();
  32.  
  33.             InputStream telnetIn = telnet.getInputStream();
  34.  
  35.             telnetOut.close();
  36.             telnetIn.close();
  37.             telnet.close();
  38.             //System.out.println(intPort + " " + " " + telnet.getRemoteSocketAddress() + " " + telnet.isConnected());
  39.         }catch(Exception e)
  40.         {
  41.             System.out.println(e.getMessage());
  42.         }
  43.     }
  44. }
  45.  
Aug 21 '07 #1
3 4236
prometheuzz
197 Recognized Expert New Member
I must say, this is not the best way to learn Java. Perhaps you should ask this friend who supplied you the code how you should be able to compile and run it.
Or learn how to do this yourself:
http://java.sun.com/docs/books/tutor...ted/index.html

Good luck.
Aug 21 '07 #2
svjames
4 New Member
I must say, this is not the best way to learn Java. Perhaps you should ask this friend who supplied you the code how you should be able to compile and run it.
Or learn how to do this yourself:
http://java.sun.com/docs/books/tutor...ted/index.html

Good luck.
I am very aware that this is not a prefered circumstance, thats why im asking for help. I just need this code to be executable from a web page. My friend has moved away... and i mean antarctica away... so if you could help me compile and rrun it, that would be good.
Aug 21 '07 #3
r035198x
13,262 MVP
I am very aware that this is not a prefered circumstance, thats why im asking for help. I just need this code to be executable from a web page. My friend has moved away... and i mean antarctica away... so if you could help me compile and rrun it, that would be good.
If you have the class files and the jar files, you don't need to compile it again. To run it from a browser, it has to be an applet. Now we're not going to make the applet for you. We just point you in the right direction. You have to appreciate that you need to put more work into it than you're asking us to put into it.
Aug 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8659
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function seems to freeze after a couple of command. I did a simplify script that reproduce the problem each time (I'm using 2.3.4 on W2K):
4
11182
by: Donnal Walter | last post by:
On Windows XP I am able to connect to a remote telnet server from the command prompt using: telnet nnn.nnn.nnn.nnn 23 where nnn.nnn.nnn.nnn is the IP address of the host. But using telnetlib, this code returns the traceback that follows: import telnetlib host = 'nnn.nnn.nnn.nnn'
2
8273
by: john brown | last post by:
I'm telnetting into a router. Apart from the fact I can't seem to view the output when iniciating the session, I can't match one of the expressions using Net::Telnet. I can telnet into the router manually without a problem. I'm running a sniffer at the same time just to see what's happening behind the scenes. The computer does an ARP request looking for the router's direction, but that seems to be it. I don't think any data actually...
4
9302
by: Tim Tyler | last post by:
Has anyone ever built a JavaScript Telnet client? What about a JavaScript SSH client? -- __________ |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
6
17168
by: Questman | last post by:
Does anyone have code they could share that would implement a telnet session in a browser using Javascript? I've seen it done once, but they did not have code available. This would be integral to preserving some old telnet-based software but allowing us to move on with web-only code at this point. Thank you in advance to anyone who can assist. (Ideally, it should be cross-browser, of course).
3
3323
by: Moogoo | last post by:
Hello all, I am new to c++, coming from a Java background. Thank you in advance for anyone that can answer the question below: GOAL: I am currently writing a shell application for a telnet session. I wish to add functionality of a command buffer/history of past commands the user has entered successfully. This action is similiar to pressing the up/down arrow on a standard prompt window and cycling through past executed commands. ...
2
1357
by: surajhs | last post by:
hi, Get me the working sample links of telnet in java
3
5032
by: bytespaulraj | last post by:
We have RHEL5 server. We could able to run Java programs through telnet But When we run Java Swing (GUI) we are getting GTK error Please help us to eliminate this error.
17
7341
by: ravimath | last post by:
Dear all, I have written following script to loin to router bu it is showing error. #!c:\Perl\bin; use strict; use warnings; my $hostname = 'REMOVED FOR YOUR PROTECTION'; my $password = 'REMOVED FOR YOUR PROTECTION';
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.