[ale] Using locally defined variable in ssh command line to remote host?

JK jknapka at kneuro.net
Thu Apr 9 12:19:35 EDT 2009


Jeff Lightner wrote:
> Question:
> 
> How can I create a variable in a script such that defining it on 
> originating host allows me to feed it its value into the ssh command 
> line on remote host?
> 
>  
> 
> Details:
> 
> I’m trying to do something like this:
> 
>  
> 
> #!bin/bash
> 
> REMSERVER=billybob
> 
> REMLOGDIR=/felix/preprod/jboss/server/default/log
> 
>  
> 
> ssh $REMSERVER 'sh -c "ls -tr  ${REMLOGDIR}/webserver.log* |xargs grep 
> -hA 10 DEBUG"'


Hmmm.  Problem is, your variable is inside a single-quoted string, so it
isn't getting expanded on the local host.  Is there a specific reason
you're not just saying

ssh $REMSERVER "ls -tr  ${REMLOGDIR}/webserver.log* |xargs grep
-hA 10 DEBUG"

?


-- JK

-- 
A closed mouth gathers no feet.


More information about the Ale mailing list