Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SSH to start a remote script..hangs.. 2

Status
Not open for further replies.

patnim17

Programmer
Jun 19, 2005
111
US
Hi,
We have Weblogic Servers running on Linux (red hat ver 4). One of the things that I am trying to do is to start the Weblogic managed instance remotely using SSH. So here is the scenario:
I have Linux Server A - has Weblogic Admin and Sever B has the Weblogic Managed instance.

Script A.sh resides on Server A and Script B.sh resides in sever B. Script B.sh starts the weblogic managed instance (that is basically a java process)
Now, Script A.sh has the SSH command to connect to server B and execute the B.sh Script and then proceeds with other tasks.So Script A.sh looks like this:
#Script A.sh
echo "Start A.sh...."
....
....
SSH user@ServerB B.sh
echo "creating file..." > test.txt
echo "status=" $? >> test.sh
....

Now, the problem that I am stuck with is, when I execute the script A.sh, the SSH command executes and starts the B.sh script in server B (whcih executed fine), but the control never comes back. SO the test.txt file never gets created. It just hangs after the SSH is executed.

I have already tried the folloing things:
1. Runing the B.sh in the background process
2. Added exit at hte end of B.sh script.

But nothing seems to work so far.

Any help would be great..

Pat

 
Sorry, don't know much about weblogic but are the management instance an X application or are is it command line interface?
 
Is B.sh supposed to start a daemon that will run continually or does that script have logic that will complete during the interactive session?

If you want B.sh to launch something that will stay running, you'll need a different approach.

D.E.R. Management - IT Project Management Consulting
 
If script B.sh is the normal Weblogic managed server startup script, then it won't return until the managed served has shut down. You may have to do something like...
Code:
ssh user@ServerB 'nohup B.sh > B.log 2>&1 &'
Or you could create a script that does the [tt]nohup[/tt] for you and call that from SSH.

The correct thing to do though would be to create and run a node manager on ServerB and use the Admin server to start and stop the managed server. That's what they're designed for.

 
SamBones,
This command seems to be working.

ssh user@ServerB 'nohup B.sh > B.log 2>&1 &'

I know "&" runs this in the background process...what does: 2>&1 doing here?

Also, thanks for your advice on Node Manager. Apparently BEA has a know issue with Nodemanagers running on Linux..so we had to abort thta plan.

thanks
PAt
 
1 = stdout
2 = stderr

2>&1 map stderr to stdout, so stderr appears interspersed and goes to the same location as stdout.

Sometimes if stderr is not redirected or suppressed (with -n) the connection will never terminate because the stderr is held open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top