How to force opening a window terminal from program

Linux specific questions.
Post Reply
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

How to force opening a window terminal from program

Post by marpon »

hi
I am using Mint XFCE 18.3 /64, (but quite newbie on linux)
how in freebasic , create a program wich can be launched from file manager and from prog request opening a terminal window to show printing items.

idealy, an universal solution for all kind of linux distributions ?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: How to force opening a window terminal from program

Post by D.J.Peters »

May be: https://www.freebasic.net/wiki/wikka.ph ... PgOpenScrn

"Opens the console directly for input and output as a file"

Joshy
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: How to force opening a window terminal from program

Post by badidea »

It is a simple question, and although a have some experience with linux, I cannot really answer the question (only some workarounds).
I think the problem is that the 'print' statement prints to 'stdout'. If the program is started from command line(terminal), then 'stdout' is probably the terminal. If the program is started form desktop or graphical file manager 'stdout' is somewhere else? /dev/null (a black hole)?
When running the program from 'geany' (a simple IDE), geany opens a terminal for you. There are multiple terminal applications for linux. In geany you can set which one to use.

Some work-arounds:
* Use a graphical screen (e.g. screen 12 / screenres x,y) then freebasic redirects 'stdout' to this screen I guess.
* Here on Ubuntu (Mate) I can create a launcher for an application on the desktop. With this launcher I can select 'application in terminal'. That works, but I get 'xterm' instead of 'mate-terminal' which uses microscopic sized characters.

A real linux geek will know the answer, hopefully there is one here...

Trying to search with Google / DDG for more information mostly gives the wrong results.
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: How to force opening a window terminal from program

Post by marpon »

D.J.Peters wrote:May be: https://www.freebasic.net/wiki/wikka.ph ... PgOpenScrn

"Opens the console directly for input and output as a file"

Joshy
it does not work in linux nor in windows
badidea wrote:It is a simple question, and although a have some experience with linux, I cannot really answer the question (only some workarounds).
I think the problem is that the 'print' statement prints to 'stdout'. If the program is started from command line(terminal), then 'stdout' is probably the terminal. If the program is started form desktop or graphical file manager 'stdout' is somewhere else? /dev/null (a black hole)?
When running the program from 'geany' (a simple IDE), geany opens a terminal for you. There are multiple terminal applications for linux. In geany you can set which one to use.

Some work-arounds:
* Use a graphical screen (e.g. screen 12 / screenres x,y) then freebasic redirects 'stdout' to this screen I guess.
* Here on Ubuntu (Mate) I can create a launcher for an application on the desktop. With this launcher I can select 'application in terminal'. That works, but I get 'xterm' instead of 'mate-terminal' which uses microscopic sized characters.

A real linux geek will know the answer, hopefully there is one here...

Trying to search with Google / DDG for more information mostly gives the wrong results.
yes i already tried wih graphical screen, but not very good solution, it would be better to force a terminal window to appear...
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: How to force opening a window terminal from program

Post by badidea »

I was looking at how 'geany' does it:
mate-terminal -e "./test"

Code: Select all

mate-terminal --help-all
  -e, --command                   Execute the argument to this option inside the terminal
Which also works with xterm:
xterm -e "./test"
My idea was to put this in a bash script, but it seems pretty useless. When you try to run a bash script from the file manager in Ubuntu, it starts asking what you want to do 'run', 'run in terminal' or 'display'. Those options are wanted for the actual program, not for the bash-script. The OS starts thinking for the user, which is nearly always a bad thing (one of the reasons I switched to linux :-( ). Also, this route is still dependent on the linux distribution, unless there is a way to figure out what the default terminal is, but this gets unnecessary complex.
Post Reply