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

Jeff Lightner jlightner at water.com
Thu Apr 9 12:01:42 EDT 2009


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"'

 

The problem is the REMLOGDIR variable is defined on originating host so
of course has no meaning on destination host. 

 

Please don't tell me to create a script on remote host and call it from
originating host - that has occurred to me but I don't really want to do
that.   If it can't be done in a single script I'll just hard code the
value in the ssh command line but I wanted to see if anyone had any
ideas.  

 

Using quoting, eval etc... doesn't work.   

 

I did find mention of a variable definition in authorized_keys in .ssh
of remote host but wasn't real sure how that worked and also am not sure
I want to add something like this to that file for fear it would impact
other ssh activity to same user from other locations.
 
Please consider our environment before printing this e-mail or attachments.
----------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20090409/45fd9f60/attachment.html 


More information about the Ale mailing list