|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a script something like this:
#!/bin/ksh function remote_host { remsh } function local_host { #some commands } #more commands local_host remote_host # Script ends I want to remsh the local_host function to a remote host (through remote_host function) and get back the output to the local host. I know remsh runs only those commands that are present in the remote hosts. Is there any worlaround for this problem. One option would be to rcp the function in the /tmp dir and run it from there. But what if I don't what to copy it to /tmp dir. Any other method? Regards, RB |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
In article <1189009841.675412.98690@57g2000hsv.googlegroups.c om>,
itsme <rachit7@gmail.com> wrote: >I have a script something like this: > > >#!/bin/ksh > >function remote_host { >remsh >} > >function local_host { >#some commands >} >#more commands >local_host >remote_host ># Script ends > >I want to remsh the local_host function to a remote host (through >remote_host function) and get back the output to the local host. I >know remsh runs only those commands that are present in the remote >hosts. Is there any worlaround for this problem. One option would be >to rcp the function in the /tmp dir and run it from there. But what if >I don't what to copy it to /tmp dir. Any other method? Assuming your shell on the remote host is ksh, and if your local_host function is one that would work properly if rcp'd over and executed, you can simply make the function be part of the command passed: rsh remote-host ' function local_host { #some commands } local_host ' If your shell on the remote host isn't ksh, you'd do approximately the same thing, but invoke ksh explicitly on the remote host with the function/invocation as its arguments. You'll have to make the quoting work. Alternately, you can send the function over as the input to the shell: rsh remote-host ksh <<\END function local_host { #some commands } local_host END John -- John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Sep 6, 3:18 pm, spce...@armory.com (John DuBois) wrote:
> In article <1189009841.675412.98...@57g2000hsv.googlegroups.c om>, > > > > itsme <rach...@gmail.com> wrote: > >I have a script something like this: > > >#!/bin/ksh > > >function remote_host { > >remsh > >} > > >function local_host { > >#some commands > >} > >#more commands > >local_host > >remote_host > ># Script ends > > >I want to remsh the local_host function to a remote host (through > >remote_host function) and get back the output to the local host. I > >know remsh runs only those commands that are present in the remote > >hosts. Is there any worlaround for this problem. One option would be > >to rcp the function in the /tmp dir and run it from there. But what if > >I don't what to copy it to /tmp dir. Any other method? > > Assuming your shell on the remote host is ksh, and if your local_host > function is one that would work properly if rcp'd over and executed, > you can simply make the function be part of the command passed: > > rsh remote-host ' > function local_host { > #some commands > > } > > local_host > ' > > If your shell on the remote host isn't ksh, you'd do approximately the same > thing, but invoke ksh explicitly on the remote host with the > function/invocation as its arguments. You'll have to make the quoting work. > > Alternately, you can send the function over as the input to the shell: > > rsh remote-host ksh <<\END > function local_host { > #some commands > > } > > local_host > END > > John > -- > John DuBois spce...@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ Thanks a lot John. I will try it. But it seems that in this case I will not be able to invoke this function in the local machine. I want to be able to use it on both local and remote machines. Thanks anyway. Regards RB |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Sep 7, 8:37 am, itsme <rach...@gmail.com> wrote:
> On Sep 6, 3:18 pm, spce...@armory.com (John DuBois) wrote: > > > > > > > In article <1189009841.675412.98...@57g2000hsv.googlegroups.c om>, > > > itsme <rach...@gmail.com> wrote: > > >I have a script something like this: > > > >#!/bin/ksh > > > >function remote_host { > > >remsh > > >} > > > >function local_host { > > >#some commands > > >} > > >#more commands > > >local_host > > >remote_host > > ># Script ends > > > >I want to remsh the local_host function to a remote host (through > > >remote_host function) and get back the output to the local host. I > > >know remsh runs only those commands that are present in the remote > > >hosts. Is there any worlaround for this problem. One option would be > > >to rcp the function in the /tmp dir and run it from there. But what if > > >I don't what to copy it to /tmp dir. Any other method? > > > Assuming your shell on the remote host is ksh, and if your local_host > > function is one that would work properly if rcp'd over and executed, > > you can simply make the function be part of the command passed: > > > rsh remote-host ' > > function local_host { > > #some commands > > > } > > > local_host > > ' > > > If your shell on the remote host isn't ksh, you'd do approximately the same > > thing, but invoke ksh explicitly on the remote host with the > > function/invocation as its arguments. You'll have to make the quoting work. > > > Alternately, you can send the function over as the input to the shell: > > > rsh remote-host ksh <<\END > > function local_host { > > #some commands > > > } > > > local_host > > END > > > John > > -- > > John DuBois spce...@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ > > Thanks a lot John. I will try it. But it seems that in this case I > will not be able to invoke this function in the local machine. > I want to be able to use it on both local and remote machines. > > Thanks anyway. > Regards > RB- Hide quoted text - > > - Show quoted text - Folks, I came up with a solution #!/bin/ksh LOCALHOST=' hostname wd;uname;$HOME' function remote_host { echo $LOCALHOST | xargs remsh REMOTE_HOST_NAME } remote_host # To run on remote host echo eval $(echo $LOCALHOST) # To run on local host. # End of script Regards, RB |
|
![]() |
| Outils de la discussion | |
|
|