2009/11/5 Min Kim <[email protected]>:
>
> Does anyone know how to make environment variables registered for
> exec_command calls when using SSHClient? I'm using a basic script that
> instantiates the SSHClient class, connects to another computer using the
> connect method, then sends out commands using the exec_command method.
> However, none of the environment variables seem to be registered when I try
> to issue commands. I can do basic things like 'ls' and see the stdout, but
> when trying to run installed programs, the fact that the environment
> variables are missing makes it impossible to run them. Using ssh in the
> command line to do the same thing works, as the environment variables for
> the user are set.
> Issuing a "source path/to/.profile" doesn't seem to do anything to future
> commands issued by the exec_command method.
if you want to mimic what ssh is doing you may try to
shell = SSHClient.invoke_shell('vt100',80,300)
shell.send(source path/to/.profile)
shell.send(command1)
shell.send(command2)
I'm not even sure that you need to "source path/to/.profile" in this case.
> But there does seem to be some
> persistence between exec_command calls, because using "sudo -s" to become a
> super user does affect future calls to exec_command.
Strange enough I don't know why since I though different "exec_command" launched
on the same SSHClient should not share much beside the authentication
and the transport.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
paramiko mailing list
[email protected]
http://www.lag.net/cgi-bin/mailman/listinfo/paramiko