2

I run an application by opening a terminal then navigating to a directory and executing ./nameofapp. The application opens in terminal and I can operate it with some other commands.

If I try to run the application from file manager, it runs in the background. How can I run it in terminal?

4
  • How do you open it outside of the command line? Is it a script or is it compiled?
    – k.stm
    Sep 16, 2018 at 13:10
  • @k.stm It is a executable file, to be concrete, in the "Properties" it says: application/x-executable. Sep 16, 2018 at 13:50
  • That’s not what I meant. In the commandline, what does $ file nameofapp say? Maybe it’s not binary, but a text file. What does $ head -n 3 nameofapp say (the first three lines of the file)? More importantly, how do you open it outsite of the command line? Double-click on it in a file browser?
    – k.stm
    Sep 16, 2018 at 14:14
  • Yes I double click it, it is a compiled application that when launched only run in the background. Sep 16, 2018 at 14:28

1 Answer 1

3

You can write a .desktop file for your application. With terminal option the application should launch in terminal:

[Desktop Entry]
Type=Application
Name=Application Name
Exec=/path/to/nameofapp
Terminal=true

Alternatively, you can write a wrapper script that starts terminal and runs your application. For example (gnome-terminal):

#!/bin/sh
exec gnome-terminal -- ./nameofapp
5
  • I tried the second option and it opens and closes inmediately, when run through terminal with "./name-of-script" it says "exec: gnome-terminal not found". Sorry for my limited knowledge, I am beginner on Linux. Sep 16, 2018 at 15:08
  • You need to call a terminal application installed on system (instead of gnome-terminal). What distribution/desktop environment are you using?
    – sebasth
    Sep 16, 2018 at 15:16
  • I am using the built-in terminal on Linux 19 Tara Sep 16, 2018 at 15:20
  • Your system possibly uses mate-terminal. Try modifying the script by replacing gnome-terminal with mate-terminal.
    – sebasth
    Sep 16, 2018 at 15:29
  • it opens the terminal but don't do anything, I guess it is a problem in the app. However, thanks a lot for your answer! Sep 16, 2018 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .