0

I am running a shell script through a web application. This shell script looks something like

`#! /bin/bash
user=""
pass=""
db_url=""
db_instance=""
sqlplus -s $user/$pass@$db_url/$db_instance @ ./SqlScripts/foo.sql
sqlplus -s $user/$pass@$db_url/$db_instance @ ./SqlScripts/bar.sql
CLASS_PATH="./lib/*"
java -classpath $CLASS_PATH package.Main ./Data/inputfile`

I am using ProcessBuilder to run the script and everything but the last line works fine. Am I creating a problem by calling shell through the jvm then calling the jvm again to run the application?

3
  • Does it give an error message? When it doesn't work fine, how do you know? :-) Commented Oct 15, 2009 at 16:07
  • No error message. There is just no output and it hangs when running through the web app. The thread enters waiting state and never leaves. Commented Oct 15, 2009 at 16:49
  • -1 for giving wrong input. Kyle it would be a lot easier if you post the actual code ( or even an actual sample ) Commented Oct 20, 2009 at 16:20

4 Answers 4

1

The problem was the environment that the script execution process was running in. I changed some of the environment variables of the process and everything is working fine now. The script was initially a standalone shell script, but I wrote one script for each of the databases used. In order to control the workflow I wrote a web application for this which calls seperate threads for each script and can manage the threads. Thanks for the responses!

Sign up to request clarification or add additional context in comments.

Comments

0

Often, app servers run their servlets in a 'clean room' environment - e.g. they strip away all the variables that would normally be set from the outside for security reasons. Try using a fully qualified path to the java binary, and also try setting a full/absolute path for your CLASS_PATH variable.

1 Comment

app servers and standalone apps, the problems is that $ENV_VAR is something the shell understand, not the program. Same goes for any other programming language.
0

The parent JVM and the child JVM should be separate processes, no particular reason why they should interfere.

What error do you get?

is java on your PATH?

OK, adding more questions in response to your comments ...

Which thread is waiting? Presumably the parent?

The child java process, do you have any evidence as to whether is succesfully initalises. My guess woukld be that the child is in some way blocked. If you kill the child does the parent then come back to life?

Suppose it was a simple "hello world" application, would that work?

1 Comment

yes java is on PATH. No error just hangs with the thread never leaving waiting state.
0

Most likely the line:

CLASS_PATH="./lib/*"

And

$CLASS_PATH

It won't be expanded by the process builder because that's usually shells' job, which in this situation is not being invoked.

Try creating the complete list of ./lib/* and append it directly into the last line of your script.

java -classpath ./lib/a.jar:./lib/b.jar

Side note:

Invoking all this from java looks just bad to me. I would rather have it in a standalone script and invoke it by other means, but that's me.

1 Comment

that was just an example... not the actual script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.