Script starts from tray and Menu but Xterm don't pop up

Booting, installing, newbie
Post Reply
Message
Author
User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

Script starts from tray and Menu but Xterm don't pop up

#1 Post by UncleScrooge »

Hi guys

related to this (SOLVED) topic:

the scripts run correctly clicking on the xxxx.desktop file from the FileManager.
Xterm pops up and the user interaction works like a charm

I also wanted them to be launched from the Menu and/or from a tray icon. So I copied them to the /usr/share/applications directory and used JWMDM to have the tray icons.

Now: the scripts start ok either by clicking on the menu item or the tray icon but no xterm window pops up.

I know they are running since they are listed in <top> (and I have to kill them as not having user interaction they will run forever)

here is an example of my desktop file:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=UDP Multicast Netstorm
GenericName=UDP Multicast Netstorm
Comment=UDP Multicast Netstorm
Categories=Network
Terminal=true
Exec=/root/NetstormUtil/UDPMulticast
Icon=/root/NetstormUtil/thndblt2.png
again, if I surf to the usr/share/applications dir and click on the desktop file they work as expected.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

UncleScrooge mate,

Bypass the desktop file and run it as explained here.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#3 Post by rcrsn51 »

Someone recently posted a nicer way to make a clickable script, but I can't find it now.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#4 Post by Semme »

:D Shame on you Bill.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#5 Post by jrb »

rcrsn51 wrote:Someone recently posted a nicer way to make a clickable script, but I can't find it now.
You may be referring to my post which works quite nicely but I have never gotten this technique to work from the JWM menu. Yours on the other hand does. 8)

Script code:

Code: Select all

#!/bin/sh
tail -n +4 $0 > /tmp/script.txt
exec rxvt -e sh /tmp/script.txt
echo Syncing...
sync
echo Sync complete.
Desktop code:

Code: Select all

Name=Sync
Exec=Sync
Terminal=false
Type=Application
Categories=Utility

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

Re: Script starts from tray and Menu but Xterm don't pop up

#6 Post by enrique »

UncleScrooge

rcrsn51 is a powerfull trick that you should not forget. You will have it handy on the future.

But you may be looking for this
UncleScrooge wrote:...

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=UDP Multicast Netstorm
GenericName=UDP Multicast Netstorm
Comment=UDP Multicast Netstorm
Categories=Network
Terminal=true
Exec=xterm -e "$SHELL -c '/root/NetstormUtil/UDPMulticast'"
Icon=/root/NetstormUtil/thndblt2.png

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

Re: Script starts from tray and Menu but Xterm don't pop up

#7 Post by UncleScrooge »

enrique wrote:UncleScrooge

rcrsn51 is a powerfull trick that you should not forget. You will have it handy on the future.

But you may be looking for this
UncleScrooge wrote:...

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=UDP Multicast Netstorm
GenericName=UDP Multicast Netstorm
Comment=UDP Multicast Netstorm
Categories=Network
Terminal=true
Exec=xterm -e "$SHELL -c '/root/NetstormUtil/UDPMulticast'"
Icon=/root/NetstormUtil/thndblt2.png
Hi enrique

this way I have an error pop up saying
Can't find Exec command in .desktop file '/usr/share/applications/UDP_Multicast.desktop'
-----
gonna try the rcrsn51 solution. Anyways, dragging the xxxxx.destops files on the screen desktop makes the xterm win to popup correctly when launching from there.
An I might be satisfied with that.
Problem is that being an old fart meself, I stubbornly don't understand why the bloody thing won't work from the popup menus and the tray.

PS: how on earth would someone choose a username as criptyc as rcrsn51 ... :shock: :D

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#8 Post by enrique »

There are many Puppys and how they have been setup.

But this error "Can't find Exec command" is easy to find solution.

This is the full line

Exec=xterm -e "$SHELL -c '/root/NetstormUtil/UDPMulticast'"

we have ONLY 3 commands. You need to find witch is faulty: xterm, $SHELL & /root/NetstormUtil/UDPMulticast

Lets start testing

1)

Code: Select all

echo $SHELL
=> should show "/bin/bash" or "/bin/sh"

2) terminal
I used xterm you can use the one you like. To test

Code: Select all

xterm -v
mine shows => XTerm(344)


3) /root/NetstormUtil/UDPMulticast
I guess this is your own program. You should know how to test it, I guess with -v or -h


4) Finally You can always execute the command in terminal to see what it shows:

xterm -e "$SHELL -c '/root/NetstormUtil/UDPMulticast'"

instead try"

/root/NetstormUtil/UDPMulticast
bash -c '/root/NetstormUtil/UDPMulticast'
sh -c '/root/NetstormUtil/UDPMulticast'
rxvt -e "sh -c '/root/NetstormUtil/UDPMulticast'"
xterm -e "bash -c '/root/NetstormUtil/UDPMulticast'"

If you see all is the same, it depends
if your use bash, sh
and what is your
terminal; xterm rxvt, lxteminal

enrique

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

Hello UncleScrooge and all.

You need a support for your CLI application if you launch it from Xorg. Your CLI
application needs to run in an (u)rxvt or MLTerm, etc., window in the X context.
Launch it without this support, of course it will be launched where you won't see it!

E.g. with top -- This is the top.desktop file I have:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=Top view running processes
Icon=/usr/share/pixmaps/puppy/execute_inspect.svg
Comment=Top view running processes
Exec=rxvt -font 7x14 -bg "#c0c0c0" -fg black -T Top -n Top -e top
Terminal=false
Type=Application
Categories=X-System-process
GenericName=Top view running processes
NoDisplay=true
Please see screen cap of the result below.

Please notice that the top command is at the end of the Exec= line, supported by
the rxvt command at the beginning and then a number of settings.

A note of caution -
In my experience, the Exec= line in the *.desktop files sometimes picks up
the command only up to the first space. Anything after that space is sometimes
ignored.

So to make sure, you could create an *.sh file (script) with your desired command
in it, and then replace the command on the Exec= line with the name of your script.

I'm not familiar with your UDPblabla command, so I'll leave you to dabble with it. I'll only
draw your attention to the fact that the Exec= line in your desktop file will need at least

Code: Select all

Exec=rxvt -e /proper/directory/UDPblabla
( -e means "execute" to rxvt )
So what you'll have is a UDPblabla.desktop file that launches rxvt that launches
UDPblabla.

IHTH
Attachments
top-launched-with-above-desktop-file.jpg
(158.1 KiB) Downloaded 83 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
UncleScrooge
Posts: 104
Joined: Tue 07 Apr 2020, 06:07
Location: Norway

SOLVED

#10 Post by UncleScrooge »

@ enrique:

there was nothing wrong with the syntax of both the *.desktop and my *.sh scripts. As I said the whole shabang was working fine as long I was launching the *.desktop file from a SymLink at the screen desktop or just clicking the .sh file from Filer.

But thnx for the hints about debugging, I am used since forever to have ever improving IDEs with intellisense, breakpoints, watch, step by step and all the shit and giggles, when I write code. meaning I got rusty when it comes to shell scripts. Plus I'm still a newbie when it comes to Unix (and Linux obv)

turns out musher0 was right on the money: I wrote another *.sh script with only a single command in there and then made the *.desktop file launching this script (and Terminal=false btw) here it is

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=UDP Multicast Netstorm
GenericName=UDP Multicast Netstorm
Comment=UDP Multicast Netstorm
Categories=Network
Terminal=false
Exec=/root/NetstormUtil/UDP_Multicast.sh
Icon=/root/NetstormUtil/multithunder.jpg
here is UDP_Multicast.sh

Code: Select all

#!/bin/sh
xterm -e /root/NetstormUtil/UDPMulticast
kinda convoluted way to achieve the result ... but who cares: works fine now from anywhere
thnx everyone for the support!!!

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#11 Post by musher0 »

@UncleScrooge:
Glad I could be of help!
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#12 Post by Mike Walsh »

(Not relevant - sorry; didn't read the thread right through..! :oops:)

Post Reply