Hi,
I need to run a script(/home/rs/Get_FileList) which is on a remote server(usnav.mh.vntnt.com), as user 'rs'. The script takes 2 arguments: requirements and 16.1. When i try to do this with JSP(code as given below), the following command is returning "null":
rt.exec(command);
JSP code:
=======================================================================================
try
{
Runtime rt = Runtime.getRuntime();
String command = "/opt/bin/ssh rs@usnav.mh.vntnt.com ksh /home/rs/Get_FileList requirements 16.1";
Process proc = rt.exec(command);
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
out.println(line);
int exitVal = proc.waitFor();
}
catch(Exception e)
{
out.println(e);
e.printStackTrace();
}
catch (Throwable t)
{
=======================================================================================
Note:
* SSH keys are configured for promptless mode.
* When i try to execute the same SSH command from command prompt, it successfully executes:
>opt/bin/ssh rs@usnav.mh.vntnt.com ksh /home/rs/Get_FileList requirements 16.1
* If i try handling stderr in the above code, it says: "Host key verification failed". But even though i remove all keys
using "ssh-keygen -R hostname" and then once again configure SSH keys, it again fails. I checked all the SSH keys in both servers. It is perfect.
* My question is do we need to configure anything else in tomcat? Because the SSH is executed successfully via command prompt and even via the shell script. The problem is only when SSH is used in JSP.
Please let me know your views.
Thanks.
I need to run a script(/home/rs/Get_FileList) which is on a remote server(usnav.mh.vntnt.com), as user 'rs'. The script takes 2 arguments: requirements and 16.1. When i try to do this with JSP(code as given below), the following command is returning "null":
rt.exec(command);
JSP code:
=======================================================================================
try
{
Runtime rt = Runtime.getRuntime();
String command = "/opt/bin/ssh rs@usnav.mh.vntnt.com ksh /home/rs/Get_FileList requirements 16.1";
Process proc = rt.exec(command);
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null)
out.println(line);
int exitVal = proc.waitFor();
}
catch(Exception e)
{
out.println(e);
e.printStackTrace();
}
catch (Throwable t)
{
=======================================================================================
Note:
* SSH keys are configured for promptless mode.
* When i try to execute the same SSH command from command prompt, it successfully executes:
>opt/bin/ssh rs@usnav.mh.vntnt.com ksh /home/rs/Get_FileList requirements 16.1
* If i try handling stderr in the above code, it says: "Host key verification failed". But even though i remove all keys
using "ssh-keygen -R hostname" and then once again configure SSH keys, it again fails. I checked all the SSH keys in both servers. It is perfect.
* My question is do we need to configure anything else in tomcat? Because the SSH is executed successfully via command prompt and even via the shell script. The problem is only when SSH is used in JSP.
Please let me know your views.
Thanks.