Re: urgent newbie question : ssh : problem with variable inside ssh session
On Wed, Jan 25, 2006 at 11:49:39AM +0100, Stephane Durieux wrote:
> Hello
>
> I have a problem in a ssh script:
> ssh host << EOF
> for o in /directory/*
> cp -pr /directory/* /other_location
That's not the whole script, is it?
You need EOF on a line by itself at the end.
You're not using the $o variable.
What do you want that "for" loop for? It's not necessary for that
copy instruction.
If you use a "for" loop, you need a "do" and a "done" to mark the
beginning and end of the instructions in the loop.
> the problem is that variable o isn t created in fact.
How do you know? The script - as you posted it - doesn't use it.
> It seems that
> the it is created on the remote machine (normal) but cannot be
> printable on the local.
> what is the reason ?
> Can someone give me in depth explanation
> I have tried --tt option whithout any result
>
> Why does it works in a interactive ssh session, the variable is
> however also created on the remote machine ?
>
In an interactive session, you're talking to a shell on the remote
machine and that shell will interpret what you write.
If you run a script on your local machine, your local shell will try
to interpret it. If you're using a "here-document" (that thing with
<<EOF), you can put quotes around EOF - <<'EOF' - to cause your
local shell to pass the text across verbatim, ie, without trying to
interpret it.
I don't know that I fully understand what you're trying to do but I
hope that helps.
Salut,
David
--
David Jardine
"Running Debian GNU/Linux and
loving every minute of it." -L. von Sacher-M.(1835-1895)
Reply to: