calling unix script from JSP???

Hi all,

i have requirement where i need to call a unix script from a JSP code. my script should list all the csv files from a directory and then should upload the file names to an oracle table (using sqlloader).

i tried using getRuntime function in JAVA to call my script and was successfully able to list all the files in that directory. but the issue i am facing is that when i added a filter of listing only csv files (ls *csv* > tempfile) then also its listing all teh files (and not only teh csv files).

one more issue here is that i have to give teh entire path of list command (/usr/bin/ls) and hence have to give path for each and every command i use further in teh script (i just tried the functionality of calling a script from JSP and then listing all files). the issue here i feel is that the unix shell is not being spawned here and thats why the basic commands are not available to teh code.

so basically teh script is not working at all :frowning: .....please help!!!!

the code i used is mentioned below:

helloworldapp.java:

import utility.ErrorPage;
import utility.ConnectionPool;
import utility.GeneralSecurity;
import utility.ErrorClass;
import javax.servlet.;
import javax.servlet.http.
;
import java.io.;
import java.sql.
;
import java.util.*;

public class HelloWorldApp extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException ,IOException
{
PrintWriter out = res.getWriter();
try
{
res.setContentType("text/html");
out.print("<HTML><HEAD><TITLE>Testing Servlets</TITLE></HEAD><BODY><H1>Hello World</H1>");
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
out.println("Before Executing script file");

            //String scriptfile="ls &gt;&gt; temp1234.txt";
            //String scriptfile="HelloWorldApp.sh";
            //String process1=scriptfile;
     //Process child = rt.exec\("/bin/ksh"\);
     //Process child = rt.getRuntime\(\).exec\("/usr/bin/ksh"\);
     //child.waitFor\(\);
     //int exitValue1=child.exitValue\(\);
     //out.println\("The Return Value of ksh : "\+exitValue1\);

    Process p1 = rt.getRuntime\(\).exec\("/home/user/HelloWorldApp.sh"\);
        p1.waitFor\(\);
        int exitValue=p1.exitValue\(\);
            out.println\("The Process to be executed is : "\);
            out.println\("The Return Value : "\+exitValue\);
            out.print\("&lt;/BODY&gt;&lt;/HTML&gt;"\);
            out.close\(\);
       \}
    catch\(Exception excpUser\)
    \{
      out.println\(excpUser.getMessage\(\)\);
    \}

    \}

}
shell script:HelloWorldApp.sh:

#!/bin/ksh

. $HOME/.profile

/usr/bin/ls > /home/user/temp1234.txt
#/usr/bin/cat temp1234.txt | /usr/bin/grep *csv* > temp1234.txt

sorry for the lengthy mail :o

regards,
Bhups.

The word is "the".

Where do default paths and such come from on your system? Could you source /etc/profile or something to get the missing things like PATH?