Hi,

You need to escape the metacharacters, so $ will be \$.
Double quotes expand variables, single quotes do not, sou cou could
just put it all in single quotes. The local system will see the $ as a
literal, but the remote system will see it as a variable.

Hope this helps some.

Nick Larsen ( http://datanet.co.nz/ )

On 7/25/05, Damian Gerow <[EMAIL PROTECTED]> wrote:
> (I don't really know /where/ to ask this question.  It's not particularly
> FreeBSD-centric, but the list has been good to me in the past, so hopefully
> nobody minds.)
> 
> I'm trying to write a shell script that runs a for loop in an SSH session.
> Simply, I'm trying to do this:
> 
>     for HOST in `cat hostnames` ; do
>         ssh ${HOST} "for PROCESS in 01 02 ; do echo '${PROCESS}' ; done"
>     done
> 
> But because this is run in a script, that gets translated to:
> 
>     for HOST in `cat hostnames` ; do
>         ssh ${HOST} "for PROCESS in 01 02 ; do echo '' ; done"
>     done
> 
> Which most definitely is not what I want.
> 
> I know a few ways around this -- expand the for loop, have a secondary
> script, create a secondary script on-the-fly, etc. -- but I'm curious to see
> if I can convince sh to *not* interpret ${PROCESS}.  I've tried escaping it,
> I've tried a double-dollar, and I've tried escaping the double-dollar: none
> have worked.
> 
> Does anyone have any ideas?
> 
>   - Damian
> 
> P.S. Please reply privately as well to the list; thanks.
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
>
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to