LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 09-23-2009, 10:37 AM   #1
amit.giri
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Rep: Reputation: 0
"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
 
Old 09-23-2009, 11:08 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
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
 
Old 09-23-2009, 11:13 AM   #3
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
Agreed with the last poster... Very simple.

Just ssh into the box and run the script.
 
Old 09-24-2009, 12:47 AM   #4
amit.giri
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 09-24-2009, 01:27 AM   #5
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638

Rep: Reputation: Disabled
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?
 
Old 09-24-2009, 04:19 AM   #6
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by amit.giri View Post
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?
 
Old 09-24-2009, 10:33 AM   #7
IanVaughan
Member
 
Registered: Jun 2009
Location: Brighton, UK
Posts: 50

Rep: Reputation: 16
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!)
 
Old 09-24-2009, 01:47 PM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Quote:
Originally Posted by amit.giri View Post
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.
 
Old 09-25-2009, 01:20 AM   #9
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638

Rep: Reputation: Disabled
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.
 
Old 10-05-2009, 10:15 AM   #10
amit.giri
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by linuxlover.chaitanya View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
converting shell script from "dialog" to "xdialog" kushalkoolwal Programming 1 02-25-2008 09:40 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
shell script to mount samba share with " " in the remote path dohpaz Programming 2 10-20-2006 03:18 PM
Remote Win Bat File execute Shell Script on AIX Server DriveMeCrazy AIX 5 05-26-2004 07:24 PM
remove the "Run or Display?" when I execute a script llee Programming 5 05-05-2003 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration