Operating System - HP-UX
1833582 Members
3549 Online
110061 Solutions
New Discussion

Re: doing some commands on a remote machine

 
Ahmed_41
Super Advisor

doing some commands on a remote machine

Dear All,

i got 2 machine machine x and y, i need to issue a command on machine x from machine y, then copy the result from machine x resulted from this command to machine y in a specific directory
can someone tell me how to do it,
thanks in advance
15 REPLIES 15
Alexander M. Ermes
Honored Contributor

Re: doing some commands on a remote machine

Hi there.
check the man pages for rexec, rlogin, rsh etc. One of these should be the right for you. And make sure, that the access from system to system is configured properly.
Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Ahmed_41
Super Advisor

Re: doing some commands on a remote machine

actually i tried to do that
i read the remsh and the rcp but i couldnt go on and do it

Victor BERRIDGE
Honored Contributor

Re: doing some commands on a remote machine

Hi,
Have you created the .rhosts in the users directory perms rwx------ ?
with for box X: Y
Y: X

I just just did on 2 trusted hpux11 box to see:
alnitak # id
uid=200(vbe) gid=2(bin)
alnitak # remsh alnitam -n "date"
Wed Feb 2 13:10:37 MET 2005
alnitak # remsh alnitam -n "date>today.test"
alnitak # rcp alnitam:/home/vbe/today.test .
alnitak # ll
total 4
-rwxr-xr-x 1 vbe bin 146 Nov 28 2000 myping
-rw------- 1 vbe bin 29 Feb 2 13:13 today.test
alnitak #

What are you trying to do?

All the best
Victor
Ahmed_41
Super Advisor

Re: doing some commands on a remote machine

i am trying to do a backup on a machine X from another machine Y, then i will take this result from this machine X and resotre it on the source machine Y

so i need to be able to issue from machine Y the backup command on Y, then copy the result from machine X to machine Y

Victor BERRIDGE
Honored Contributor

Re: doing some commands on a remote machine

Wouldnt it be easier to:
Box Y:
tar -cf - | remsh X "(cd ; tar -xvf -)" ?
Ahmed_41
Super Advisor

Re: doing some commands on a remote machine

victor,
easy on me i am not that good in HPUX OK :) that is why i am asking
i got from the line you wrote that

system will go do a tar on box X for the backup directory and then it will be piped so it will be untared in the box Y

is that correct ???
and what is the difference between this and my idea, cuz in my idea i wanted to copy the whole files and directory strcutre that will result from the backup script ???

Victor BERRIDGE
Honored Contributor

Re: doing some commands on a remote machine

Well,
The other way round you archive Y and extract on X...
The difference? Mainly the space for the archive you have to spare on both boxes with your solution...

All the best
Victor
Victor BERRIDGE
Honored Contributor

Re: doing some commands on a remote machine

Me again...
Have you tried my little test just to see you can remote command...
Because I was wondering if you have some configuration not allowing... have a look at the inetd configuration, look at /etc/inetd.conf

All the best
Victor
Ahmed_41
Super Advisor

Re: doing some commands on a remote machine

Victor,
yes i did try the remsh and the rcp and they are working
i need to put the logic togther now to get it done

i am not sure why i am unable to do it may be that is why i need the help

as i told you, i am trying to make backup on machine X from machine Y, then copy the result of the backup to machine Y

i do have the space on both machines so this is not a worry
Victor BERRIDGE
Honored Contributor

Re: doing some commands on a remote machine

What commands are you trying to use, in order for me to try also...

Kind regards
Victor
Mohanasundaram_1
Honored Contributor

Re: doing some commands on a remote machine

Hi Ahmed,

Assuming you want to copy a directory subtree from Machine Y to Machine X. here is what I will do

1) At machine X
a) Create /.rhosts file and add 2 lines


2) At Machine Y, repeat the step (1.a)

3) login as root from Machine Y
4) try rlogin
This should log you in to Machine X without password.
5) From Machine X try
rlogin
Again login should happen without password.

6) Now You must be in Machine Y. Assuming you want to copy /tmp/your_dir

# rcp -r /tmp/your_dir :/

7) check at your Machine X if you got the files. if so, you can proceed.

If not, write back with the problem you encountered.

With regards,
Mohan.
Attitude, Not aptitude, determines your altitude
Ahmed_41
Super Advisor

Re: doing some commands on a remote machine

that was quite descriptive, but i need to do the reverse
to copy from the remote machine to the local machine
which means

assuming i am in Machine Y

i wanna copy while i am in machine Y to machine X
so is that possible ??


Gordon  Morrison
Trusted Contributor

Re: doing some commands on a remote machine

Hi Ahmed,
I think the easiest way to do what you want (as I understand it) would be to write a script

that sits on machinex and execute it from machiney via remsh.

e.g.
#!/bin/ksh
# A simple backup script
cd /wherever
tar cf whatever.tar *
gzip whatever.tar
rcp whatever.tar.gz machiney:/mydir/


Then execute it from machiney:
remsh machinex /yourdir/backup.ksh

The above script will require .rhosts entries on both machines. e.g.
on machinex:
machiney root

on machiney:
machinex root

If you don't want .rhosts files all over the place, remove the last line of the script, then

you can do it all from machiney:
remsh machinex /yourdir/backup.ksh;rcp machinex:/wherever/whatever.tar.gz /mydir/

Hope that helps
What does this button do?
Mohanasundaram_1
Honored Contributor

Re: doing some commands on a remote machine

Hi Ahmed,

Yes, the reverse is possible.

From Machine Y,

1) Login as root
2) rcp -r :/

is this what you want to do? Give a thought about the script suggested by Morrison.

Also you should read the man pages of rcp to understand clearly if it provides what you are looking for.

Hope this helps.

With regards,
Mohan.
Attitude, Not aptitude, determines your altitude
B. Hulst
Trusted Contributor

Re: doing some commands on a remote machine

Hi,

But be aware that using remsh or rexec is not secure. Some systems are not allowing this kind of remote execution.

Regards,
Bob

Ps. My 0.02 euro.