Score:1

Migration python procject from ubuntu to ubuntu server

sd flag

I have few days experience with ubuntu server and apologize for stupid questions.

I wrote python program wich work fine on Ubuntu 18.04LTS. Now i am trying to run the same program on UBUNTU SERVER. Inside the scropt I have subprocess call like that:

subprocess.call(["gnome-terminal", "--", "bash", "-c", string_as_parameters ])

When I am trying to run on Ubuntu server I have error:

[Error2] No such file or directory: 'gnome-terminal'

If I want to run program on both server and normal ubuntu, how should I call subprocess? If is not possible, how to change my code for ubuntu server?

Soren A avatar
mx flag
Ubuntu-server is pure command-line interface, no graphical programs / GUI.Therefor gnome-terminal (or any other graphical programs) is not installed.
luki avatar
sd flag
That I know now. How to resolve my problem? Should I call subprocess program as normal python program and make all prints to file? Is other way? Can I call new comand line interface?
Soren A avatar
mx flag
I am not a python programmer, but isn't it possible to call and execute bash directly ?. without any need for grapichal support Also that problem might better be asked in a programming forum - and with a more clear description on what you are trying to implement.
user535733 avatar
cn flag
For Ubuntu Server, simply omit the first two items of the list.
cocomac avatar
cn flag
Does this answer your question? [How to execute a program or call a system command?](https://stackoverflow.com/a/89243/16886597) - @SorenA Yes, it is. You would do `subprocess.call(["bash", "-c", string_as_parameters])`.
luki avatar
sd flag
This call fixed my problem: subprocess.Popen(['python3', path_to_file, arg1, arg2], preexec_fn=os.setpgrp) . I could not use subprocess.call because i have 3 subprocesses in one script and first program are waiting for finising firs call.
luki avatar
sd flag
we can close this question
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.