-----Original Message-----
From: Abhinav Jain 
Sent: Thursday, May 23, 2002 2:11 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Re: JSP to trigger a Unix script


hi 
As I mentioned in my first mail that the JSP application and the Unix server where I 
have to connect are 2 different machines.
So I cannot directly use java.lang.Runtime class. I guess, first I need to telnet to 
the unix server. This telnet should also be done by the JSP application.

Got this from one of the web sites.
I am pretty new to JSP so I will need your help to tell me if this one does work.

*********************************************************************************
public class TelnetSession
extends de.mud.telnet.TelnetWrapper

This class can be used to establish telnet connections with the desired device. Has 
methods to set the Telnet Socket timeout and read buffer size. The following is a 
example code which uses the TelnetSession to establish a Telnet Connection and 
send/receive commands to/from a device: 


        String host = "localhost"
        TelnetSession session = new TelnetSession();
        session.setPrompt("$");
        try{
                session.connect(host, 23 ) );
                session.setSocketTimeout(5000);
                System.out.println("Session opened with :" + host); 
        }catch(Exception ae){
                System.out.println("Session unable to connect with " + host);
                System.exit(0); 
        } 
  try{
        String response = session.send("ls"); // send the command eg "ls".
                System.out.println("Response: " + response); //print the response
        }catch(Exception e){
                System.out.println("Error in Sending the command" + e);
        }
        The above code will open a Telnet connection to the localhost, sends a command 
and the received response is displayed. 
*****************************************************************************************

regards
-abhinav
-----Original Message-----
From: Rodrigo Ruiz Aguayo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 1:37 PM
To: [EMAIL PROTECTED]
Subject: Re: JSP to trigger a Unix script


Yes. You need a way to execute applications remotely in the server. Check if you can 
do a rexec from the server in which Tomcat resides to the target server.

If this works (or any alternative), read the javadoc of java.lang.Runtime class. It 
declares some exec() methods that can help you.

Regards

abhinavjain wrote

Hi Folks, 
The problem goes like this...... 
I have a JSP app(which i have to write) on Tomcat server. 
Now I have a Unix server in which I have to trigger a nohup script using this JSP 
application. 
Can a JSP program do this job for me? 
Note : The JSP app and the Unix server are different. 
JSP gurus kindly help me on this 
thanks 
abhinav 

==========================================================================To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to