edh@ux.acs.umn.edu (Merlinus Ambrosius) (04/03/91)
Is it possible to do this? #!/bin/sh RHOST=apple-gunkies rsh $RHOST 'echo here I am on $RHOST!' When I try this, it says "RHOST undefined". I am sure this is because the shell on the remote host doesn't have RHOST defined (of course). Is it possible to pass the definition of RHOST on through the rsh? Thanks very much for any help, --eric
jik@athena.mit.edu (Jonathan I. Kamens) (04/04/91)
In article <3688@ux.acs.umn.edu>, edh@ux.acs.umn.edu (Merlinus Ambrosius) writes: |> #!/bin/sh |> RHOST=apple-gunkies |> rsh $RHOST 'echo here I am on $RHOST!' Use double quotes instead of single quotes. variable substitutions occur inside double quotes, but not inside single quotes. Observe: % /bin/sh $ RHOST=apple-gunkies $ echo "here I am on $RHOST!" here I am on apple-gunkies! $ echo 'here I am on $RHOST' here I am on $RHOST Quoting from our sh(1): A character may be quoted by preceding it with a \. \new- line is ignored. All characters enclosed between a pair of quote marks (''), except a single quote, are quoted. Inside double quotes ("") parameter and command substitution occurs and \ quotes the characters \ ' " and $. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710
calvin@sequent.com (04/04/91)
In article <3688@ux.acs.umn.edu> edh@ux.acs.umn.edu (Merlinus Ambrosius) writes: >Is it possible to do this? > >#!/bin/sh >RHOST=apple-gunkies >rsh $RHOST 'echo here I am on $RHOST!' > >When I try this, it says "RHOST undefined". I am sure this is because the >shell on the remote host doesn't have RHOST defined (of course). Is it >possible to pass the definition of RHOST on through the rsh? you might try using double quotes. that way the variable $RHOST gets parsed before the rsh is executed. Calvin Goodrich / calvin@sequent.com / a\=k)4vk!%t@$+... <EOT> (beep!) "Scotty, we need that .sig in thirty seconds or we're all dead!" "Och, Captain! We canna do anathin'! It's still on yir other account!" -- Starfleet. It's not just an adventure, it's a job. --
dag@fciva.FRANKCAP.COM (Daniel A. Graifer) (04/06/91)
In article <3688@ux.acs.umn.edu> edh@ux.acs.umn.edu (Merlinus Ambrosius) writes: >Is it possible to do this? > >#!/bin/sh >RHOST=apple-gunkies >rsh $RHOST 'echo here I am on $RHOST!' Other people correctly pointed that the single quotes are preventing the local shell from substituting the variable, and taht double quotes would prevent this. I prefer: rsh $RHOST 'echo here I am on `uname`!' Dan -- Daniel A. Graifer Coastal Capital Funding Corp. Sr. Vice President, Financial Systems 7900 Westpark Dr. Suite A-130 (703)821-3244 McLean, VA 22102 uunet!fciva!dag fciva.FRANKCAP.COM!dag@uunet.uu.net