[ale] Using locally defined variable in ssh command line to remote host?
Jeff Lightner
jlightner at water.com
Thu Apr 9 12:56:24 EDT 2009
Yes. Because when I use the double quotes it tries to list the files on
the local host rather than the remote one so results in:
ls: /felix/preprod/jboss/server/default/log/log/webserver.log*: No such
file or directory
As I said I've tried various quoting, escaping, eval methods. The issue
is they all make it either pass the variable (not its value) to the
other side so it doesn't know the value or they evaluate parts of the
command locally where they have no relevance.
It just seems really odd to me that ssh doesn't have something built in
that would allow it to process a locally defined variable on the remote
side. I see many have asked the question but didn't see any obvious
solution.
-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of JK
Sent: Thursday, April 09, 2009 12:20 PM
To: Atlanta Linux Enthusiasts - Yes! We run Linux!
Subject: Re: [ale] Using locally defined variable in ssh command line to
remote host?
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.
_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
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.
----------------------------------
More information about the Ale
mailing list