[Gambas-user] Finding if app is launched from terminal or not

Tobias Boege tobs at taboege.de
Tue Jun 29 11:09:22 CEST 2021


On Tue, 29 Jun 2021, Bruce Steers wrote:
> Hi all, I have an app that uses lame to make mp3s from wav files and lame
> puts info out to stdout as it works.
> 
> It's primary use is going to be either drag-n-drop files onto a launcher or
> right clicking files and choosing open with app.
> Both those cases will not have a terminal so the app opens up it's own
> terminalview form and runs the command in it.
> 
> but the app could also be run from terminal in which case it would not need
> the terminalview and could just output to stdout.
> 
> But i do not know of a good way to detect if the app has been run from a
> terminal or i need to open it's own one.
> 

File.In.IsTerm is true if and only if the standard input of your program
is connected to a (pseudo) terminal. This will be the case when you launch
the program in a terminal emulator. It will also be the case if you launch
it in the IDE (because it is connected to the TerminalView in the IDE).
It will be false if you launch it via double click from your desktop.

Best,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list