0

pls help me in this immediately...

Problem with JAVA command in shellscript..

I have a script Cachereload.sh in one server which has the following command:

java -jar SingMgmnt.jar $4 $2 $3 sixdee sixdee $5

This is working very fine when i run it from the same server.

But i want to run this script from another server and i did it as

ssh [email protected] 'sh -c "./Cachereload.sh"'

which will prompt for the password, and after that it executes the script. But then I'm getting an error,

./CacheReload.sh: line 4: java: command not found

But only java command is not working i think.. bcoz pwd, ls and even mysql command is working fine from remote server itself..

Please help me out..

Thanking you All Akhil

2
  • 1
    Did you try googling "linux java: command not found" and looking at the thousands of answers for the error you're seeing? Commented Nov 24, 2010 at 15:43
  • 1
    Maybe a question to serverfault? Commented Nov 24, 2010 at 15:44

2 Answers 2

2

This will be related to your ssh environment differing from the environment of an interactive shell. For example, assuming you're using bash your .bashrc file will only be sourced for interactive shell environments. So if you're setting your PATH variable within your .bashrc file it will only take effect for interactive shells.

A simple workaround is to refer to the absolute path of the java binary within your Cachereload.sh script.

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

1 Comment

Thank u very much Adamski... But can u tel me the way how to refer to the absolute path of the java binary within the sh file ? I'm new to shell scripting actually.. And also, is there any other way to set the PATH variable so that even ssh environment can see the JAVA path ? If I can be success in this calling java command from remote server, what I acheive thru dat wil b great..so please help me.. Thanks in Advance..
0

what happens when the oracle user runs this command on the server, not via the one line ssh.

Its quite likely that java is not in the PATH for this user (possibly not install at all).

1 Comment

Thanx Peter.. Ya, dats wat i told, from oracle user at the same server, its working fine and so Java is installed at the server.. only while doing thru ssh, I'm getting this problem.. Thanx in advance..

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.