Pergunta

I have an Ubuntu server which has a python script that runs a terminal command-based interface. I'm using plink to login and immediately execute the python script:

plink.exe -ssh -l goomuckel -pw greenpepper#7 192.168.1.201 "python server.py"

However, I get the following message:

TERM environment variable not set.

So I created a sh script (server.sh) on the Ubuntu machine:

export TERM=xterm
python server.py

Using the following plink command:

plink.exe -ssh -l goomuckel -pw greenpepper#7 192.168.1.201 "sh server.sh"

Now I don't receive the warning anymore, it seems that the python script is execute. But instead of showing the terminal interface I'm printing in the python script, only the following characters are printed:

←[H←[2J

The weird thing is, when logging in manually with Putty and executing the python script, everything works fine. I've tried adding the -t flag to plink and then the script executes. However I'm using colors for printing the terminal text, and the colors are printed as text rather than changing the colors of the text as observed in Putty.

Any ideas what I can do?

Foi útil?

Solução

You don't need to do this into a python script.

You could simply modify .profile -that is a file that system will execute on every login - with the same expression you use into python script

export TERM=xterm

(if you use bash)

setnv TERM xterm

(for c-shell and similar)

Outras dicas

I had the same problem and setting the TERM variable before the command eliminated that TERM environment variable not set. error message:

plink.exe -ssh -l goomuckel -pw greenpepper#7 192.168.1.201 "export TERM=xterm; python server.py"

This is handy if you can't modify the .profile file...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top