Pergunta

I'm writing a Python program that runs on Linux server. It monitors some log file and displays lines from that log file in a GUI, based on a given keyword.

I added a new feature that opens a terminal window with "less" showing the line that the user double-clicked on in my program.

My problem is this: When i run my program locally (on my computer) it works perfectly. But when I run my program from the main server while connected to it via SSH, the programs runs well, but when I double-click one of the lines, I see a console window that opens and closes quickly.

Here is the code that responsible for opening the "Less Terminal":

p = subprocess.Popen(args = ["gnome-terminal", "--command = less -p " + "\"" +searchString + "\"" " -j 10 " + "\"" + path + "\""], stdout = subprocess.PIPE) 

How can I keep it open?

P.S. If I add shell = TRUE, it just opens a new terminal window without the less results.

Foi útil?

Solução

My problem wasn't related to ssh; I managed to recreate it on my local machine. When testing the program locally, I used short pattern strings for testing, but when I moved to the server and started to use the actual strings, they were too big!

What happened is: I gave less a pattern bigger then 99 chars. And I got: "ungetcc overflow", a known bug, which was subsequently fixed in version 438 of less.

Outras dicas

It work for me

if sys.platform != "win32": sp.Popen(command.split(), shell=False)
else: sp.Popen(command.split(), shell=True)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top