Operating System - HP-UX
1844160 Members
2281 Online
110229 Solutions
New Discussion

In script, how to remote run a script

 
SOLVED
Go to solution
Gary L
Super Advisor

In script, how to remote run a script

Hi

I have being writing a script, there is a action need remote start a script, how to do it, details as below:

Server A: rp5470 11i v1 scriptA
Server B: rp4440 11i v1 have been writing scriptB
Server A - B connect allow SSH, telnet, remsh.

In scriptB I wanna add a action that run remote run scriptA, how to do it.

Any answers, will be very appreciate.

-G
11 REPLIES 11
Gary L
Super Advisor

Re: In script, how to remote run a script

Sorry, the title should be:
How to remote start another script that located in another server in a script.
Tim Nelson
Honored Contributor
Solution

Re: In script, how to remote run a script

ssh host scriptB
or
remsh host scriptB

If scriptB requires interaction with tty then this will not work.
Gary L
Super Advisor

Re: In script, how to remote run a script

Hi Tim

Thank you very much for your fast reply, Does you mean:

In ServerB, scriptB I just add below items and could remote start scriptA on serverA?


serverB > # cat scriptB
...
remsh serverA /home/oracle/scriptA.sh

exit

that's everyting? what't the remsh passwd?
Tim Nelson
Honored Contributor

Re: In script, how to remote run a script

1) Yes the script would look like you indicated.

2) In order for remsh to work without a password prompt you need to correctly configure the trust relationship. i.e. configure ./rhosts in users home directory.

For ssh you need to configure .ssh/authorized_keys file.


trust access is a different subject from your topic but can describe if needed.


Gary L
Super Advisor

Re: In script, how to remote run a script

Yes, .rhosts is what i am thinking about.

thanks a lot.

It works now,

BTW,

the file should be .rhosts not ./rhost right?
Tim Nelson
Honored Contributor

Re: In script, how to remote run a script

yes plural.

$HOME/.rhosts

format:
hostname username
Gary L
Super Advisor

Re: In script, how to remote run a script

thanks Tim.

One more question,

If I remote access to serverA but this server need enter some enviroment parameter like d0 [DEV50] d1 [DEV51], normally, the oracle user will enter d0 or d1 after input username and passwd and then in the DEV50, oralce could run the script serverA.
How to write this in scriptB, in other words, how to let the script execute d0

remsh serverA
d0 ???
sh scriptA
Tim Nelson
Honored Contributor

Re: In script, how to remote run a script

tty interaction with this is a problem.

I would recommend passing variables into the script. You will have to mod the script to accept these args and set the vars you want.

i.e.

remsh serverA "script.ksh arg1 arg2"

Dennis Handly
Acclaimed Contributor

Re: In script, how to remote run a script

One thing to remember about remsh in a script, you should use the -n option so it doesn't eat up your commands following the remsh:
remsh machine -n command
Yogeeraj_1
Honored Contributor

Re: In script, how to remote run a script

hi,

in case, you decide to use SSH, below an extrace from a script that we currently use here:
...
ssh applnuser@SRV1 << EOF
/home/yogeeraj/compile.sh /appln/$4/$2/$3/$1
EOF
else
...

hope this helps too!
kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Gary L
Super Advisor

Re: In script, how to remote run a script

Hi Dennis and Yogeeraj

Thank you very much for your detail reply.

Have a good day.

-G