Operating System - HP-UX
1833323 Members
2833 Online
110051 Solutions
New Discussion

execute script on other UNIX machine?? how

 
amonamon
Regular Advisor

execute script on other UNIX machine?? how

Helloo..I was trying to write a script that could execute from my solaris machine script on rel. UNIX ..

how can I use or can I use rlogin or rsh to execute script

script is on: /path/to/script/script

ip address of machine that should be accessed is 192.168.168.5

username: user1
pass: userpass

Any help is appretiated...thanks


12 REPLIES 12
James R. Ferguson
Acclaimed Contributor

Re: execute script on other UNIX machine?? how

Hi:

First, you need to establish a 'hosts.equiv' or '.rhosts' file on both servers. See the manpages for 'hosts.equiv(4)' for this.

You will also want to make sure the '/etc/inetd.conf' has the 'login', 'shell' and 'exec' services enabled.

The manpages for 'remsh(1)' offer additional information for you.

Regards!

...JRF...
Timothy P. Jackson
Valued Contributor

Re: execute script on other UNIX machine?? how

Hi,

I use .rhosts, it seems easier to setup then hosts.equiv. Make sure that the .rhost is in the home directory of the user.

The man pages for .rhosts is very good and will show you exactly how to set it up.

If you are at all interested in Sarbens Oxly, they kind of frown on this. If you setup your .rhosts completely, you can usually talk them out of it. So make sure that you not only have the system name but also the user name in the .rhosts.

Here is an example of a command

remsh hp1 -n "/sbin/init.d/sendmail stop"

Tim
amonamon
Regular Advisor

Re: execute script on other UNIX machine?? how

well...from one machine I can easy do rsh but I want to add this to shell script...
Do I need to edit those files??

rsh and rlogin work already...I just can not figure how to add those commands to my script?? so it can run automaticly when I start my script...

thanks..
Victor BERRIDGE
Honored Contributor

Re: execute script on other UNIX machine?? how

Easy:
octant:/home/vbe $ remsh mairan "date"
Fri Jun 30 10:22:23 METDST 2006
octant:/home/vbe $


All the best
Victor
amonamon
Regular Advisor

Re: execute script on other UNIX machine?? how

?? I am now confused...


I want in my shell script among other thing to write so that machine can connect to other machine and execute script in other machine...

I can do it in commands..

rlogin IPaddress

then I am asked for pass. and bingo I am on other machine then change dir. and execute script...

But I want it in first machine to have all that in shell script so I just execute script on machine A...machine does login to machine B and execute script on amchine B...of course while I am on machine A..

Please sorry if I confused U but could not figure easyer way to explan U..

Thanks for help..
Peter Nikitka
Honored Contributor

Re: execute script on other UNIX machine?? how

Hi,

the script needs to be accessible on hostB when you execute it:
In this script fragment called from your sun
...
thishost=sun
hphost=hp
rsh $hphost /path/to/script/script
echo fini on $hphost
...
the pathname '/path/to/script/script' gets resolved on $hphost.

If this is not the case, you'll have to transfer this file to $hphost first and then call the requested interpreter (e.g. perl, ksh):
...
thishost=sun
rcp /path/to/script/script $hphost:/tmp
rsh $hphost 'ksh /tmp/script'
echo fini on $hphost
...

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"
spex
Honored Contributor

Re: execute script on other UNIX machine?? how

amonamon,

From 'man remsh':

The remote account name used is the same as your local account name, unless you specify a different remote name with the -l option. In addition, the remote host account name must also conform to other rules which differ depending upon whether the remote host is operating in a Kerberos V5 Network Authentication, i.e., secure environment or not. In a non-secure, or traditional environment, the remote account name must be equivalent to the originating account; no provision is made for specifying a password with a command. For more details about equivalent hosts and how to specify them, see hosts.equiv(4). The files inspected by remshd on the remote host are /etc/hosts.equiv and $HOME/.rhosts (see remshd(1M)).

So you should not be prompted for a password when you 'rlogin' or 'rsh'. If you are, ~/.rhosts is not configured correctly and/or you are not logging in as the proper user. You must fix this, as "no provision is made for specifying a password with a command". To log in as a different remote user:

# rsh -l -n

So in your script, you would put:


#!/usr/bin/sh
rsh hpux_server -l user1 -n /scripts/script_to_run.sh
echo "Done."


Note that '/scripts/script_to_run.sh' is on the remote server.

PCS
amonamon
Regular Advisor

Re: execute script on other UNIX machine?? how

thank for help..but by typing rsh 192.168.125.44 I get connected but if I call that in script as U mentioned like this:

#!/usr/bin/sh
rsh 192.168.129.85 -n /fileOn/other/machine/script


I get Permission denied.

I am new in solaris world..so..please any explanation is very very welcome..:)

Peter Nikitka
Honored Contributor

Re: execute script on other UNIX machine?? how

Hi,

you MUST have passwordless connections from hostA to hostB for a successful call of

rsh hostB 'command' (on HP-UX read: remsh ...)

There is no difference there between SUN, HP, ...

When you have setup this - do like the other collegues in the forum told - this will succeed.

If you want to have interactive entering a psssword with remoute command execution, use 'ssh'.

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"
Peter Nikitka
Honored Contributor

Re: execute script on other UNIX machine?? how

Hi,

you MUST have passwordless connections from hostA to hostB for a successful call of

rsh hostB 'command' (on HP-UX read: remsh ...)

There is no difference there between SUN, HP, ...

When you have setup this - do like the other collegues in the forum told - this will succeed.

If you want to have interactive entering a password with remote command execution, use 'ssh'.

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"
Peter Nikitka
Honored Contributor

Re: execute script on other UNIX machine?? how

Hi,

you MUST have setup passwordless connections from hostA to hostB for a successful call of

rsh hostB 'command' (on HP-UX read: remsh ...)

There is no difference there between SUN, HP, ...

When you have setup that - do it like the other collegues in the forum told you - this call will succeed.

If you want to have interactive entering a password with remote command execution, use 'ssh'.

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"
Peter Nikitka
Honored Contributor

Re: execute script on other UNIX machine?? how

Sorry for posting multiple - I hate Server error 500 .
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"