0

I have the following line of code

print linuxCommand.execute_ssh_command("xterm -e \"cd /home/;./lapras.sh; bash\" &", True, False)

It wont open the graphic terminal,I can do it manually with a script or running another script, also the test is running on a Debian session in a server.

Anmol Gautam
  • 949
  • 1
  • 12
  • 27
xChapx
  • 91
  • 1
  • 1
  • 5

1 Answers1

0

Print a command on terminal is not the same thing that use him.

You can use subprocess to call a bash command on python:

import subprocess subprocess.call("date")

Your bash command use args so you can use subprocess like that:

subprocess.call(["command1", "arg1", "arg2"])

More info: https://www.cyberciti.biz/faq/python-execute-unix-linux-command-examples/

Lucas Araújo
  • 429
  • 5
  • 17
  • Hello the thing is that the subprocess executes on windows and it should do it in the debian sesion, do you know how i can do that? – xChapx Oct 30 '18 at 18:46
  • I'm not sure if i understand your problem, do u want to send a terminal command to another machine, that is it? – Lucas Araújo Oct 30 '18 at 20:13
  • Yes, I am on a windows computer and I want to open xterm and send a command in another computer with debian – xChapx Oct 30 '18 at 20:19
  • Ok, you can use paramiko third-party library, this library basically uses SSH-protocol to send terminal commands to another computer. With that you will no longer need an graphical interface. More info: https://github.com/paramiko/paramiko Related answer: https://stackoverflow.com/questions/28411960/execute-a-command-on-remote-machine-in-python – Lucas Araújo Oct 31 '18 at 02:34