Sponsored Content
Top Forums Shell Programming and Scripting calling unix script from JSP??? Post 302075812 by Bhups on Wednesday 7th of June 2006 02:39:25 AM
Old 06-07-2006
Question 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 Smilie .....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 >> 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("</BODY></HTML>");
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 Smilie

regards,
Bhups.
 

10 More Discussions You Might Find Interesting

1. Programming

calling UNIX script from C/C++

Hi all, Is it possible to call a UNIX script from C/C++ program? If yes, can you please tell me how? Thank you in advance Regards (3 Replies)
Discussion started by: omran
3 Replies

2. Shell Programming and Scripting

Help with shell script - Unix Gurus calling

Unix Gurus, I have been breaking my head to get this done..seems simple.. I need to read a flat file and based on a key word in a line, i need to skip the previous 3 lines. eg : Line1 Line2 Line3 Line4 Line5 Line6 Error Line7 Line8 Line9 Error Line10 (4 Replies)
Discussion started by: ravred
4 Replies

3. UNIX for Advanced & Expert Users

calling plsql function in a unix script

Could anyone please help me. I have a function in plsql that returns a number. But i am listing some records through that function using DBMS_OUTPUT.PUT_LINE. I want to catch those records by executing this function through a unix script. The following shows what i did echo "Connected from... (2 Replies)
Discussion started by: cobroraj
2 Replies

4. Shell Programming and Scripting

Can we call JSP file from Unix.if so how.Please help me.Im newbie to Unix

Hi Can we call a jsp page from Unix.if so please let me know how we can.. thanks for the help in advance... thanks kumar (0 Replies)
Discussion started by: mailsukumar
0 Replies

5. UNIX for Advanced & Expert Users

Calling unix script from sql or plsql

Hi Can anyone please let me know how to call unix scripts from sql or plsql ASAP. (2 Replies)
Discussion started by: ksailesh
2 Replies

6. Shell Programming and Scripting

Calling a request set from Unix shell Script

Hi All, I want to call a concurrent request set from a shell script. I am getting the syntax error "syntax error at line 417 : `(' unexpected" in the below script. v_request_id=fnd_request.submit_request(application => 'APPL_SHORT_NAME' ,program => 'PROGRAM_SHORT_NAME' ... (4 Replies)
Discussion started by: swatipevekar
4 Replies

7. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

8. Shell Programming and Scripting

Calling Java Method from UNIX using shell script

Hi All, I need to call a java method from a shell script. I know we can use the command java ClassName to call the main method in it. But I need to call another method that is there in the class and pass an email to it. Can I use java ClassName.MethodName(email) Any help will be... (4 Replies)
Discussion started by: RahulK
4 Replies

9. UNIX for Dummies Questions & Answers

calling a unix shell script from sqlplus

I want to execute a shell script from sqlplus prompt and get its output back to sqlplus. Is this possible? if yes just give me an example for doing that. (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

10. Shell Programming and Scripting

Calling another Script from Command Line in UNIX

Hi all, I am having problem in understanding the following line of code .. /home/rmsbatch/autoscript/autorms.ksh dc_load_main.ksh -q belk_dc_load_tran_data.seq What's being done here ? what does "-q" means ? What does ".seq" file means in unix "belk_dc_load_tran_data.seq" Please... (3 Replies)
Discussion started by: LoneRanger
3 Replies
INSTALLSIEVE(1) 					      General Commands Manual						   INSTALLSIEVE(1)

 *

NAME
installsieve - user utility for managing sieve scripts SYNOPSIS
installsieve DESCRIPTION
installsieve is a utility that allows users to manage their sieve scripts kept on the server. OPTIONS
-v <name> View script with the given name. The script if retrieved sucessfully is output to standard output. -l List all of the scripts currently on the server. If one of the scripts is active a arrow is printed indicating that it is the active script. -p <port> Port to connect to. If left off this defaults to "sieve" as defined in /etc/services. -i <file> Install a file onto the server. If a script with the same name already exists on the server it is overwritten. Upon sucessfully putting the script on the server the script is set active. If <file> has the extension .script it is chopped when put on the server since sieve names may not contain a '.'. -a <name> Set <name> as the active script. The list of available names can be obtained from the '-l' option.. -d <name> Delete the sieve script on the server with <name>. -m <mechanism> Force installsieve to use <mechanism> for authentication. If not specified the strongest authentication mechanism is chosen. -g <name> Get the sieve script with <name> and save it to disk with a ".script" extension. If a file with that name already exists it is overwritten. -u <user> Userid/Authname to use for authentication; by default, the current user. CMU
Project Cyrus INSTALLSIEVE(1)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy