Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-23-2009, 10:37 AM
|
#1
|
LQ Newbie
Registered: Sep 2009
Posts: 3
Rep:
|
"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
|
|
|
09-23-2009, 11:08 AM
|
#2
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
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
|
|
|
09-23-2009, 11:13 AM
|
#3
|
Member
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393
Rep:
|
Agreed with the last poster... Very simple.
Just ssh into the box and run the script.
|
|
|
09-24-2009, 12:47 AM
|
#4
|
LQ Newbie
Registered: Sep 2009
Posts: 3
Original Poster
Rep:
|
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
|
|
|
09-24-2009, 01:27 AM
|
#5
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep:
|
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?
|
|
|
09-24-2009, 04:19 AM
|
#6
|
Member
Registered: Sep 2009
Distribution: Fedora
Posts: 835
Rep:
|
Quote:
Originally Posted by amit.giri
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?
|
|
|
09-24-2009, 10:33 AM
|
#7
|
Member
Registered: Jun 2009
Location: Brighton, UK
Posts: 50
Rep:
|
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!)
|
|
|
09-24-2009, 01:47 PM
|
#8
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
Quote:
Originally Posted by amit.giri
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.
|
|
|
09-25-2009, 01:20 AM
|
#9
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep:
|
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.
|
|
|
10-05-2009, 10:15 AM
|
#10
|
LQ Newbie
Registered: Sep 2009
Posts: 3
Original Poster
Rep:
|
Quote:
Originally Posted by linuxlover.chaitanya
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 06:45 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|