On Mon, 13 Mar 2006, Hans-Werner Hilse wrote:

Hi,

On Mon, 13 Mar 2006 20:14:33 +0000 (WET)
Jorge Almeida <[EMAIL PROTECTED]> wrote:

I want something like this:
myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand $myvar
[...]
This does not work, because remotebox doesn't know about $myvar. Of
course, if I could pass a variable to remotebox, the line might be just
command="~/bin/mycommand" <public-key>
and the ssh command would be
myvar="whatever" ssh [EMAIL PROTECTED] ./bin/mycommand
(the program itself would use the value of $myvar)

Hm, I think you're making it unnecessary complex. What's wrong with
just piping it on stdin? I.e.:
Indeed. The problem was me not understanding the relation of stdin with
ssh when in non interactive mode...

local$ echo "whatever" | ssh [EMAIL PROTECTED] ./bin/mycommand
and in ./bin/mycommand:
---
#!/bin/sh
read myvar
# do whatever
---
I tested and it works great. It seems I have a lot to learn although I
use ssh daily with no problems. <SIGH>

Or do you in fact use a pseudo tty on remote side for interactive mode
(which would make this a little more difficult)?

If you want to keep your way of doing it, I just have a few hints, but
didn't test anything, just looked them up out of curiosity:
- read "man sshd_config", item AcceptEnv, PermitUserEnvironment
I knew about PermitUserEnvironment and SendEnv, but somehow I missed
AcceptEnv... Anyway, AcceptEnv seems to be global, wich is not what I
want.
- read "man sshd", section LOGIN PROCESS
You lost me here! I can't see relevancy---PermitUserEnvironment allows
to use variables but not to set them from local. Anyway, stdin is the
answer.

Thank you.

-hwh


--
Jorge Almeida
--
gentoo-user@gentoo.org mailing list

Reply via email to