Operating System - HP-UX
1753878 Members
7106 Online
108809 Solutions
New Discussion

Re: Help me: How to execute script in a remote host

 
SOLVED
Go to solution
Hoang Chi Cong_1
Honored Contributor

Help me: How to execute script in a remote host

Hi all
I am really stuck with this case:
I have three servers (HP-UX 11.i): ServerA, ServerB and ServerC
I have username "opr1" in all servers and I can login each other with rlogin.

Now, from serverA (with "opr1" user)I want to make a script that copy a file from serverC to ServerA and then update that file. After that, copy that file from ServerA to ServerB and then execute a script to update this file again.
The script like:

# Copy a file "file_name" from ServerC to ServerA
rcp -p ServerC:/apps/file_name /apps/
{
Update "file_name"......
..........
..........
}
# Copy file "file_name" from ServerA to ServerB

??????
??????
# Execute a script to update this file in ServerB
?????
?????

Please help me!
Thanks in advance.
Looking for a special chance.......
10 REPLIES 10
Indira Aramandla
Honored Contributor

Re: Help me: How to execute script in a remote host

Hi Hoang,

Update you /etc/hosts.equiv, and .rhosts files which will enable you to remote login and remote copy.

Then remote copy the file using rcp

change the directory to where you want to copy

rcp â p hostname:/path/filename .

edit the file

then copy back to the other server

rcp filename hostname:/path/



IA
Never give up, Keep Trying
Victor Fridyev
Honored Contributor

Re: Help me: How to execute script in a remote host

Hi,

First of all, you have to provide rcp and remsh execution without a password request by editing ~opr/.rhosts on serverB and serverC (add ServerA hostname into the file).
Let's suppose that the script which updates the file called /apps/update.sh
#Copy a file "file_name" from ServerC to ServerA
rcp -p ServerC:/apps/file_name /apps/
#Update "file_name"
/apps/update.sh
# Copy file "file_name" from ServerA to ServerB
rcp -p /apps/file_name serverB:/apps/.
# Execute a script to update this file in ServerB
remsh serverB /apps/update.sh

Best

Entities are not to be multiplied beyond necessity - RTFM
Yogeeraj_1
Honored Contributor

Re: Help me: How to execute script in a remote host

HI,

implementation using ssh would be much simpler.

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Hoang Chi Cong_1
Honored Contributor

Re: Help me: How to execute script in a remote host

Thanks all for your replies...

Now I want to execute a script in ServerB from ServerA.
I can use
<>remsh ServerB ls

But I can not execute a script in ServerB from ServerA:
<>remsh ServerB /tmp/myscript.sh
The screen out put:
ksh: /tmp/myscript.sh: not found


Has any idea?
Looking for a special chance.......
uadm26
Super Advisor

Re: Help me: How to execute script in a remote host

Hi,
The script you to execute need to be in the server, that will be executed.
Put /tmp/myscript.sh in the ServerB, check that have permissions to execute. If you can to that command without asking for password the schema it's the correct:
# rmsh ServerB date
or
# rmsh ServerB -l user date


Good luck,
Joel
Peter Nikitka
Honored Contributor

Re: Help me: How to execute script in a remote host

Hi,

you have to put the script first to this serverB:
<>rcp /apps/file_name ServerB:/tmp/myscript
Note, that there my be no execution bit set on this script, so better call the shell directly:
<>remsh ServerB sh /tmp/myscript.sh

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Hoang Chi Cong_1
Honored Contributor

Re: Help me: How to execute script in a remote host

Seem it works...
But there are some command (application command) in the script doens't work :-(

It said: not found???


Looking for a special chance.......
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Help me: How to execute script in a remote host

If you are seeing "not found" then it means just what it says. The command is not in your PATH on the remote machine. This really means that if you are executing /xxx/yyy/zzz.sh on the remote machine then /xxx/yyy/zzz.sh needs to explicitly set and export any needed environment variables including PATH itself.
If it ain't broke, I can fix that.
Hoang Chi Cong_1
Honored Contributor

Re: Help me: How to execute script in a remote host

Hm...I really forgot it...Yes...the PATH.
I will set now...
Thanks A. Clay Stephenson.
Have a nice weekend :)
Looking for a special chance.......