Operating System - Linux
1828036 Members
2533 Online
109973 Solutions
New Discussion

Re: executing a function by remsh

 
Maciej Szewczykowski
Frequent Advisor

executing a function by remsh

hi all,
i have the following question: there is a script i wrote and within it there's a function defined. i'd like this function to be executed on remote host using 'remsh' command. is this possible? do i need to apply a special -option while doing 'remsh'? (the function mentioned is supposed to read folder names within a certain directory, then 'read' output is stored as variable).
thank you in advance.
5 REPLIES 5
Claudio Cilloni
Honored Contributor

Re: executing a function by remsh

I think you should write a script containing the function code, copy this script to the remote machine and run it using remsh.

Alternatively (but I'm not so sure here), you can use remsh to run the shell interpreter (/bin/sh or whatever it is) and send the function/script code to interpreter's stdin. I think that remsh could pass its own stdin to the stdin of the command executed on the remote machine; but exactly I don't know how.

hth
Claudio

P.S.: aren't you speaking about HPUX? I haven't found remsh in my linux box...
Sergejs Svitnevs
Honored Contributor

Re: executing a function by remsh

try something like this:

script1:
...
STATUS=`remsh REMOTE_HOST "script2"`
if [ $STATUS -eq 0 ]
then
echo "Success"
else
echo "Fail"
fi
...

script2:
...
if [ $? -eq 0 ] # or something else to give back the exit-status of script2
then
echo 0
else
echo 1
fi
exit

Regards,
Sergejs
Jerome Henry
Honored Contributor

Re: executing a function by remsh

And, adding to Claudio's tip, remsh in Linux box is rsh command (man rsh), but ssh is much prefered most of the time as rsh is said to be weak as far as security is concerned...

J
You can lean only on what resists you...
Caesar_3
Esteemed Contributor

Re: executing a function by remsh

Hello!

You need that this script will be on the other
machine so you can before rsh made the rcp
for the script and then made rsh

Caesar
Jairo Campana
Trusted Contributor

Re: executing a function by remsh

also you can use more security with
openssh - the scp
srs - the srsclient
http://www-it.desy.de/support/help/uco_documentation/sshhowto.html
legionx