Telneting to a remote host and executing unix shell script

I am using VPN.I want to telnet to a remote server and execute some script there and show it the output in my front end..is it easily possible thru java..i know it can be easily done thru Python...can anyone let me knw if this can ve achieved properly thru java..thnx plz let me knw ASAP.
[295 byte] By [profilemia] at [2007-11-27 4:18:04]
# 1
You either write a telnet client or use an existing one.You can look in jakarta commons for an existing one.
jschella at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 2
I have downloaded the jar files for jakarta commons and jakarta oro..but not really getting there..Although i can telnet i am failing to give the user id/passwd to my remote server...can u plz help me with the code?
profilemia at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 3
You need commons/net: http://jakarta.apache.org/commons/net/ http://www.theserverside.com/tt/articles/content/BTS_Jakarta_Commons_Net/article.html
BIJ001a at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 4

> I have downloaded the jar files for jakarta commons

> and jakarta oro..

> but not really getting there..Although i can telnet i

> am failing to give the user id/passwd to my remote

> server...can u plz help me with the code?

I don't understand the question.

You do of course need to write code that correctly delivers the user/pwd in the way that the server expects.

Have you written that code?

If yes then the error number that is returned will tell you what problems there are.

If not then why not? If you don't know how telnet works at all then you are going to need to find a tutorial on that before you can use the API (any API for that matter.)

jschella at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 5

Yes surely I have wriiten the code..

I have first used a Socket to connect to teh host at port 23.

Then i am using outstream to give the user and passwd .. but in my Inputstream i am getting some vague outputs (some symbols..$,%,etc..) This is the code for ur reference....

import java.net.*;

import java.io.*;

class Telclient {

public static void main(String args[]) {

int c;

try{

Socket s=new Socket("abc.net",23);

InputStream in=s.getInputStream();

OutputStream out=out.getoutputStream();

String str="user" + "\n" + "password" + "\n";

byte buf[]=str.getBytes();

out.write(buf);

while((c=in.read()) != -1) {

System.out.println((char)c);

}

s.close();

}

}

Please help with teh code , bcoz its not really working..Need urgent helpI also used TelnetClient from jakarta , but failing to understand

how to use those classes to use..can anyone show me an example...

profilemia at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 6
You have to do more than download the JAR. You have to use it. Creating your own socket and reading/writing your own data doesn't constitute using it.
ejpa at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 7
I have tried to use the TelnetClient class from that downloaded jar ...but i cannot use it properly..can u show me the code for this telnet stuffs..
profilemia at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 8
I have no idea but you could have done 5 seconds further research and found this: http://www.informit.com/guides/content.asp?g=java&seqNum=40&rl=1
ejpa at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...
# 9
Ohh..grt thanx , I think this will help me a lot to overcome this stuff..However from the next time ,I will be spending those 5 secs from u + 5 secs from me... :-))...
profilemia at 2007-7-12 9:24:46 > top of Java-index,Core,Core APIs...