1833758 Members
2454 Online
110063 Solutions
New Discussion

remsh vs. rlogin

 
SOLVED
Go to solution
Dan Rosen
Frequent Advisor

remsh vs. rlogin

Hi everyone,

I am writing a script to copy a database between two servers. Basically, shut down the database on both servers, copy, then restart both. To do this, I need to run commands locally on both machines.

Initially, I was trying to use rlogin in a script, issue 4-5 commands on the remote system, exit the remote system, then continue with the rest of the script.

I was having trouble, so I think remsh will work, but I have to issue a separate remsh line for each work item, correct?

Is the best way to do this?

Below is a sample of what I was trying to do:

rlogin system2
./shut.reports
./start.reports
exit

Is this preferred/better?:

remsh system2 /scripts/shut.reports
remsh system2 /scripts/start.reports

TIA
6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: remsh vs. rlogin

I would lean towards remsh:

remsh system2 -n /scripts/shut.reports

Though, for security reasons, you should probably take a look at secure shell:

http://www.software.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA


Pete

Pete
Rick Garland
Honored Contributor

Re: remsh vs. rlogin

remsh $SYSTEM -n ""

do include the double quotes

Devender Khatana
Honored Contributor

Re: remsh vs. rlogin

Hi,

Yes , the second option seems to be a better option especially when you do it through script.

This is what we also use.

HTH,
Devender
Impossible itself mentions "I m possible"
Bob_Vance
Esteemed Contributor

Re: remsh vs. rlogin

You can do multiple commands in one 'remsh' (or 'ssh') by simply separating the commands with an escaped semicolon :

... myhost# remsh remhost hostname \; pwd \; id \; cd /tmp \; pwd

Or, you can simply quote the entire command list:

... myhost# remsh remhost 'hostname ; pwd ; id ; cd /tmp ; pwd'

You could, therefore, run your scripts with one 'remsh' thusly:

... myhost# remsh system2 /scripts/shut.reports \; /scripts/start.reports

I do things like that quite often for stopping/restarting remote services.

**However**, be aware that your environment will not be set completely when doing a 'remsh' (it is not an interactive login and .profile, etc., are not sourced). This includes PATH, which will be set to a minimal value. You can see this clearly from the following command:

... myhost# echo $PATH ; remsh remhost echo \$PATH

Be sure to escape the 2nd $ in the above; otherwise, $PATH will be evaluated locally, *before* being passed to 'remsh' !
You will see that the PATH returned from the remote execution is minimal.
Here's an example technique that I use very often to get around this between similar systems:

... myhost# remsh remhost PATH=$PATH \; cust-command

where cust-command would be in some location that would not be in the normal minimal $PATH. Notice, here, the *lack* of single quotes around $PATH. This means that it will be evaluated locally before being passed to 'remsh' and then PATH will be set the same as on the local system as part of the remote command.

If your scripts are written to use absolute pathnames or to set $PATH appropriately (which sub-system start/stop scripts usually are), then this is not a concern.

You can extend this to other vars as well:

... myhost# remsh remhost PATH=$PATH \; export V1=foo \; cust-command

Or, just source a non-interactive file that sets the required vars, including PATH:

... myhost# remsh system2 . /scripts/.setVars \; /scripts/shut.reports \; /scripts/start.reports

(notice the " . " before /scripts/.setVars)

HTH
bv
"The lyf so short, the craft so long to lerne." - Chaucer
Nguyen Anh Tien
Honored Contributor

Re: remsh vs. rlogin

I remcommand you use secure shell for better security.
HP is simple
Dan Rosen
Frequent Advisor

Re: remsh vs. rlogin

Thanks for your help, and thorough explanation of remsh!