LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "URGENT"How can i execute shell script from a remote server ? (https://www.linuxquestions.org/questions/linux-newbie-8/urgent-how-can-i-execute-shell-script-from-a-remote-server-757267/)

amit.giri 09-23-2009 09:37 AM

"URGENT"How can i execute shell script from a remote server ?
 
Hi all,

Problem statement:I have configured passwordless ssh between two servers A & B.Now i want to start & stop one tomcat server(instaled on sever B) from server A.

I am executing this command: ssh serverA " sh cd {path to the directory where tomcat is installed) startup.sh"

Error message:"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program."

But both java_home & jre_home is defined correctly on server-B in ~/.bash_profile.

Please provide help in this.
Regards
Amit giri

schneidz 09-23-2009 10:08 AM

why is this urgent ? (i almost didnt click on it)

i would do:
Code:

ssh serverA "/path/to/startup.sh"
if that doesnt work
Code:

ssh serverA
/path/to/startup.sh


manwithaplan 09-23-2009 10:13 AM

Agreed with the last poster... Very simple.

Just ssh into the box and run the script.

amit.giri 09-23-2009 11:47 PM

I guess both of you have not read the entire problem statement.
 
I am facing problems with the JAVA_HOME setup on server B.
The script that i want to trigger requires JAVA_HOME.

Now when i checked on server B for JAVA_HOME i found that it was configured correctly in ./bash_profile.

Regards

linuxlover.chaitanya 09-24-2009 12:27 AM

But if you want to run the command on server A, the variable should be defined there. Is not it? Or am I still missing something?

lutusp 09-24-2009 03:19 AM

Quote:

Originally Posted by amit.giri (Post 3694246)
Hi all,

Problem statement:I have configured passwordless ssh between two servers A & B.Now i want to start & stop one tomcat server(instaled on sever B) from server A.

I am executing this command: ssh serverA " sh cd {path to the directory where tomcat is installed) startup.sh"

Error message:"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program."

But both java_home & jre_home is defined correctly on server-B in ~/.bash_profile.

Please provide help in this.
Regards
Amit giri

The problem is that you are trying to run a program on server A. The fact that server B is set up correctly has no bearing on the problem.

To run a program on server A, server A must be set up correctly, whereas server B's setup won't be of any benefit.

Your command --

Code:

ssh serverA " sh cd {path to the directory where tomcat is installed) startup.sh"
-- tries to start tomcat on server A, not B. Is this what you intended?

IanVaughan 09-24-2009 09:33 AM

What about shell type/env setup?
SSH with and without command gives different results? env is different?

works as expected
Code:

[a ~]$ ssh 172.24.40.100
Last login: Mon Jan  1 06:07:24 2001 from 172.24.41.78
[b ~]# /path/script.sh

gives me error consistent with env setup
Code:

[a ~]$ ssh 172.24.40.100 /path/script.sh
Which implies the latter is running the script.sh on host a, when I want to
'launch' in from a, and 'run' it on b!?

(Was posted here but better here!)

schneidz 09-24-2009 12:47 PM

Quote:

Originally Posted by amit.giri (Post 3695078)
I am facing problems with the JAVA_HOME setup on server B.
The script that i want to trigger requires JAVA_HOME.

Now when i checked on server B for JAVA_HOME i found that it was configured correctly in ./bash_profile.

Regards

your urgent question is fubar to begin with. just define the needed variables on the server you are running the command on.

linuxlover.chaitanya 09-25-2009 12:20 AM

AND.....the OP is gone. After getting help the OP does not even care to come back and say if the issue is resolved or not.

amit.giri 10-05-2009 09:15 AM

Quote:

Originally Posted by linuxlover.chaitanya (Post 3696395)
AND.....the OP is gone. After getting help the OP does not even care to come back and say if the issue is resolved or not.


Hey i am still here but my problem get resolve by defining the JAVA_HOME explicitly in my script that i am executing. i.e i defined export JAVA_HOME="path to java_home on server B".

Anyways thanks alot for your precious time.

Regards
Amit giri


All times are GMT -5. The time now is 04:02 PM.