LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Desktop shortcut to CLI app (https://www.linuxquestions.org/questions/linux-desktop-74/desktop-shortcut-to-cli-app-4175592311/)

Altoid 10-26-2016 08:11 PM

Desktop shortcut to CLI app
 
Hello:

I check my FW status with fwlogwatch by opening up Gnome-Terminal and enter this command line ...

Code:

fwlogwatch -d -n -e  /var/log/ufw.log
The CL runs, I can see the output and then it comes back to the command prompt.

To have it at hand and not type it out every time (or have to make sure it is in the buffer), I add a launcher on the desktop with the CL.
Apparently it runs but the terminal won't stay open so I can see what's going on.

I checked the "Sticky" option in the launcher Properties --> Permissions tab but it behaves the same way.

What am I missing?
Man Gnome-Terminal does not give me any info on this.

I run Mint 18 64 bit - 4.4.0-45-generic #66-Ubuntu SMP - Cinnamon desktop.

Thanks in advance.

A.

dijetlo 10-29-2016 11:04 AM

Take a look at zenity. It works on a principle I entirely support.

I'm simple --> It's simple

Habitual 10-29-2016 11:09 AM

Code:

fwlogwatch -d -n -e  /var/log/ufw.log | less
should keep it open until the last screen full anyway.

Turbocapitalist 10-29-2016 11:27 AM

What does your .desktop file for that script look like?

Altoid 10-29-2016 12:27 PM

Hello:
Quote:

Originally Posted by Habitual (Post 5624491)
Code:

fwlogwatch -d -n -e  /var/log/ufw.log | less
should keep it open until the last screen full anyway.

Sorry but no, it does not even open the Gnome-Terminal.

Please note that what I want is to have a launcher on the desktop (which I will label FW) that will 1) open Gnome-Terminal and 2) run the CL
Code:

fwlogwatch -d -n -e  /var/log/ufw.log
and with just one click of the mouse (ie: one step only), leaving Gnome-Terminal open so I can see the print-out.

I can of course do it in two steps ie: 1) open Gnome-Terminal 2) type
Code:

fwlogwatch -d -n -e  /var/log/ufw.log
if it's not at hand in the buffer.

So ...
If it can be done in two steps, why can't in be 'shortcutted'? (I did this in all MS-Windows from 3.11 on ...)

I am in the impression that this is a Gnome-Terminal thing, I just cannot find it in the man page.

Thanks for your input.

A.

Turbocapitalist 10-29-2016 12:47 PM

Quote:

Originally Posted by Altoid (Post 5624509)
Please note that what I want is to have a launcher on the desktop (which I will label FW) that will 1) open Gnome-Terminal and 2) run the CL
Code:

fwlogwatch -d -n -e  /var/log/ufw.log
and with just one click of the mouse (ie: one step only), leaving Gnome-Terminal open so I can see the print-out.

You need to write a .desktop file for your script. Here is the spec, which though authoritative, is otherwise unhelpful : https://specifications.freedesktop.o...y-spec/latest/

However, you can use it as a basis for customization. It will look something like this:

Code:

[Desktop Entry]
Version=0.1
Name=FW Log Watch
Comment=some comments about what this is for
Exec=/usr/local/bin/fwlogwatch -d -n -e /var/log/ufw.log | /usr/bin/less
Icon=/home/altoid/Icons/.svg
Terminal=true
Type=Application
Categories=Utility;Application;

You'll have to fill in real values. But once you have it in place, you can click on it using your file manager and it will launch your script.

Altoid 10-30-2016 06:28 AM

Hello:

Sorry for the delay in answering.
Was away from my rig for a while.

Quote:

Originally Posted by Turbocapitalist (Post 5624512)
You need to write a .desktop file for your script.

OK.

Quote:

Originally Posted by Turbocapitalist (Post 5624512)
Here is the spec, which though authoritative, is otherwise unhelpful ...

Quite so.
Thanks.

Quote:

Originally Posted by Turbocapitalist (Post 5624512)
Code:

[Desktop Entry]
Version=0.1
Name=FW Log Watch
Comment=some comments about what this is for
Exec=/usr/local/bin/fwlogwatch -d -n -e /var/log/ufw.log | /usr/bin/less
Icon=/home/altoid/Icons/.svg
Terminal=true
Type=Application
Categories=Utility;Application;

You'll have to fill in real values. But once you have it in place, you can click on it using your file manager and it will launch your script.

Thanks.
It worked after I managed to find the place where the bloody fwlogwatch was located.
It's just that I still carry years of MS-Windows within.

Code:

[Desktop Entry]
Comment=check FWblocks
Terminal=true
Name=FWLog
Exec=/usr/sbin/fwlogwatch -d -n -e /var/log/ufw.log
Type=Application
Icon=

I later found out that the "Create a new launcher here" in the Cinnamon desktop drop down menu would do the same if when I browsed for the file to write the command line in the box, I could see it: the "Browse" button does not show hidden files nor is there a drop down to select "Show hidden files", you just have to know where it is.

Now, if I keep the
Code:

| /usr/bin/less
bit in the script, I get a small drop down below the menu bar with the legend "The child process exited normally with status 1" with a "Relaunch" button to the right and an 8 line high light opaque grey space.

For the script to work
Code:

| /usr/bin/less
has to be snipped out and then the drop down below the menu bar reads "The child process exited normally with status 0."

But although it gives me the info I want to see, not only the terminal window does not return to the command prompt like when I run the script in two stages (ie: open terminal -> type commandline + enter) but the 8 line high opaque grey space blocks the essential fwlogwatch summary.

ie: all this info is blocked from view:

Code:

fwlogwatch summary
Generated Sunday October 30 07:29:01 ART 2016 by Julius Henry Marx,,,.
31 of 31 entries in the file "/var/log/ufw.log" are packet logs, 4 have unique characteristics.
First packet log entry: Oct 30 06:58:03, last: Oct 30 07:27:29.
All entries were logged by the same host: "groucho".
All entries are from the same chain: "[UFW BLOCK] ".
All entries have the same target: "-".
All entries are from the same interface: "wlx647002073edd".

I only get to see this and not all the info:

Code:

Oct 30 08:19:57 37 igmp packets from 192.168.1.1 (-) to 224.0.0.1 (all-systems.mcast.net) port 0
Oct 30 08:20:06 37 igmp packets from 192.168.1.1 (-) to 224.0.0.251 (-) port 0
Oct 30 07:01:29 2 udp packets from fe80::6670:2ff:fe07:3edd (-) to ff02::1 (ip6-allnodes) port 8610
Oct 30 07:01:29 2 udp packets from fe80::6670:2ff:fe07:3edd (-) to ff02::1 (ip6-allnodes) port 8612

To actually see the summary, I have to hit "Relaunch" and it will print (complete) out below the first result.
Besides that, the programme cannot be stopped/aborted through the terminal with ctrl+x.

Not coming back to the command prompt I can live with but the summary is important to see.

The Edit -> Profile Preferences -> Command menu offers three options: Exit the terminal, Restart the command and Hold the terminal open (what is happening now). Nothing about the info at the top of the window.

Any idea as how to solve this?

Thanks a lot to all for your input.

Have a good week-end.

A.

Turbocapitalist 10-30-2016 06:42 AM

Ok. You can get it to go a prompt with a little modification:

Code:

Exec=/bin/bash -c '/bin/date | /usr/bin/less; /bin/bash'
That launches "bash" with the -c option which executes what's in the quote.

I think there might be a smoother way, but I think that modification will get you started.

Altoid 10-30-2016 08:01 AM

Hello:
Thanks a lot for the fast reply.

Quote:

Originally Posted by Turbocapitalist (Post 5624790)
Ok. You can get it to go a prompt with a little modification:
Code:

Exec=/bin/bash -c '/bin/date | /usr/bin/less; /bin/bash'
That launches "bash" with the -c option which executes what's in the quote.

Sorry ...
Code:

Exec=/bin/bash -c '/usr/sbin/fwlogwatch -d -n -e /var/log/ufw.log'
... makes no difference in the output.

But in the example you have kindly sent me, I do not get a command prompt back.
I get this ...
Code:

Sun 30 Oct 09:52:21 ART 2016
(END)

... with a warning that the process is still running when I try ti close the terminal as it is not responsive to any keystroke combination to close it.

In any case, not getting back to the command prompt once I get the log output is really not much of a problem as I can relaunch the app and thus have an update if I opt to keep the terminal open.

The real problem is the blank grey panel that blocks 8 lines of the first run's output.

Thanks for your input.

A.

Turbocapitalist 10-30-2016 09:05 AM

That's missing a part. Follow "fwlogwatch" part with another shell like in the example above in #8. That way you have "bash -c" calling your program plus another shell.

Code:

Exec=/bin/bash -c '/usr/sbin/fwlogwatch -d -n -e /var/log/ufw.log; /bin/bash'
or

Code:

Exec=/bin/sh -c '/usr/sbin/fwlogwatch -d -n -e /var/log/ufw.log; exec /bin/bash'
Or some such variation.

Altoid 10-30-2016 09:52 AM

Hello:
Quote:

Originally Posted by Turbocapitalist (Post 5624819)
That's missing a part.

I see ...
Sorry.

Quote:

Originally Posted by Turbocapitalist (Post 5624819)
Follow "fwlogwatch" part with another shell like in the example above in #8.
That way you have "bash -c" calling your program plus another shell.

OK.

Code:

Exec=/bin/bash -c '/usr/sbin/fwlogwatch -d -n -e /var/log/ufw.log; /bin/bash'
That did it ... =-)
The grey panel hiding the first 8 lines has gone away.

And I get the command prompt back although I still get a warning that a process is still running when I try to close the terminal and the 'Relaunch' button is gone.

Works OK for now.

Thanks a lot for your help.

Cheers,

A.


All times are GMT -5. The time now is 11:08 AM.