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) -
import java.io.*;
-
import java.net.*;
-
-
public class TelnetClient {
-
-
/**
-
* @param args - host, port, username, password
-
*/
-
public static void main(String[] args)
-
{
-
//System.out.println("Starting");
-
//System.out.println(args[0] + " " + args[1] + " " + args[2] + " " + args[3]);
-
new TelnetClient(args[0], args[1], args[2], args[3]);
-
}
-
-
public TelnetClient(String host, String port, String username, String password)
-
{
-
//System.out.println(host + " " +port + " " + username + " " + password);
-
try
-
{
-
int intPort = Integer.parseInt(port);
-
Socket telnet = new Socket(host, intPort);
-
-
//System.out.println(intPort + " " + " " + telnet.getRemoteSocketAddress() + " " + telnet.isConnected());
-
-
PrintWriter telnetOut = new PrintWriter(telnet.getOutputStream());
-
telnetOut.println(username);
-
telnetOut.println(password);
-
String exit = "quit";
-
telnetOut.println(exit);
-
telnetOut.flush();
-
-
InputStream telnetIn = telnet.getInputStream();
-
-
telnetOut.close();
-
telnetIn.close();
-
telnet.close();
-
//System.out.println(intPort + " " + " " + telnet.getRemoteSocketAddress() + " " + telnet.isConnected());
-
}catch(Exception e)
-
{
-
System.out.println(e.getMessage());
-
}
-
}
-
}
-
3 4236
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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):
|
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'
|
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...
|
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.
|
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).
| |
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.
...
|
by: surajhs |
last post by:
hi,
Get me the working sample links of telnet in java
|
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.
|
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';
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |