Interactive Commands

F

Ferruccio Vitale

Hi All,

is there a way to execute interactive command from java?
For example, I'd like to exec ssh and use stdin/stdout/stderr
like in shell.
I was not able to do it by using Runtime.exec().
Any ideas?

Regards,
Ferruccio
 
J

Joona I Palaste

Ferruccio Vitale said:
is there a way to execute interactive command from java?
For example, I'd like to exec ssh and use stdin/stdout/stderr
like in shell.
I was not able to do it by using Runtime.exec().
Any ideas?

Runtime.exec() returns a Process, which has methods getInputStream()
and getOutputStream(). All you need is some code to connect these to
System.in and System.out, respectively.
 
J

Jeff Schwab

Joona said:
Runtime.exec() returns a Process, which has methods getInputStream()
and getOutputStream(). All you need is some code to connect these to
System.in and System.out, respectively.

ssh might give you a headache by wanted to be run in a terminal. The
way to get around this in other languages is typically Expect:

http://expect.nist.gov/

I'm not sure whether Expect is available for Java.
 
J

Joona I Palaste

ssh might give you a headache by wanted to be run in a terminal. The
way to get around this in other languages is typically Expect:

I'm not sure whether Expect is available for Java.

Seeing as SSH1 and SSH2 are open protocols (at least I think they are),
there's nothing stopping someone from writing a Java class implementing
an SSH client. Actually, there is already a Java applet implementation
of SSH, known as MindTerm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top