problem with environment detecting
Ben Lindstrom
mouring at etoh.eviladmin.org
Tue Mar 12 13:57:40 EST 2002
On Tue, 12 Mar 2002, Maxim Ryabenko wrote:
> Hello!
>
> I want to detect some environment on a remote host (in C program, getenv()),
> but it is failed. Here is a little program which I try to run on a remote
> host with command: "#ssh myhost myecho"
>
> /* myecho */
> #include <stdio.h>
> main (){
> char *dir;
> if ((dir = getenv("MYDIR")) != NULL)
> printf ("environment is %s\n",dir);
> else
> printf ("enviroment is not specified.\n");
> }
>
> it returns "enviroment is not specified.", although the environment MYDIR is
> specified in /etc/profile on a remote host.
> In this way I can detect only $PATH, $USER, $HOSTNAME, but not MYDIR :(
>
> On the other hand "./ssh myhost echo $MYDIR" works correctly
>
First off do: ./ssh myhost echo \$MYDIR
All $xx and * are resolved BEFORE commands run.. the escape ensure it is
not.
Second /etc/profile is not read by non-tty sessions.
try: ssh -t myhost echo \$MYDIR
to see if you get better results.
- Ben
More information about the openssh-unix-dev
mailing list