Shell Script with curl works on terminal but not as menu launcher.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Shell Script with curl works on terminal but not as menu launcher.
Hello friends Happy New Year.
I have a question because I have a problem to apply a simple script as a launcher click to execute in terminal and auto use curl that have wttr.in as target.
If I directly put this command on terminal he works →
Code:
$ bash -x /home/joao/.config/tempo.sh
This tempo.sh have this lines →
Code:
#!/usr/bin/env bash
curl https://wttr.in/chaves
The problem when I try to do a launcher to execute the script he simply open the terminal and do nothing. Here is the launcher sintax →
The $PATH part is optional but often a good idea for scripts which will be used in an automated manner.
Then invoke the script like this:
Code:
Exec=/home/joao/.config/tempo.sh
And one more thing, the placement of your script would be better /home/joao/bin/ instead. Everything has a place. If you need the output of curl to be within /home/joao/.config/ then you can save it there:
The $PATH part is optional but often a good idea for scripts which will be used in an automated manner.
Then invoke the script like this:
Code:
Exec=/home/joao/.config/tempo.sh
And one more thing, the placement of your script would be better /home/joao/bin/ instead. Everything has a place. If you need the output of curl to be within /home/joao/.config/ then you can save it there:
I try all your suggestions and dont work the comman /home/joao/.config/tempo.sh or /home/joao/bin/tempo.sh specified directly on terminal works but in a launcher only opens terminal and do nothing.
I would add some echo commands to that script, like echo started.
And also I would redirect its output into a logfile.
Adding set -xv at the beginning also may help (to find the reason).
With this command the terminal will still open and appear to do nothing but the output will be written to a file. I would pick another location but it should still work.
If you want to see the output in the terminal window you need to pause your running script
Code:
#!/bin/bash
curl https://wttr.in/chaves
read -p "Press any key to continue"
In terminal you target the script in my case now I have two paths :
/home/joao/.config/tempo.sh
/home/joao/bin/tempo.sh
the content of scripth (.sh file) is →
Code:
#!/bin/bash
curl https://wttr.in/chaves
read -p "Press any key to continue"
When I open a terminal like lxterminal and put the target script he runs →
$/home/joao/.config/tempo.sh
You can test this on your system copy the script, put on a file .txt like tempo.txt, rename the file to .sh like tempo.sh view permissions or pass the chmod command to the file execution permissions - chmod +x /path/to/your/file.sh.
Copy te file and put on a path of your current user /home/user/tempo.sh or ~ /tempo.sh and run it (~ - means your current user folder - home).
So because this I can see the script works when I run it specifiyng directly the path on terminal but for some reason when I do a a launcher to be executed in terminal he dont works.
Because the launcher does not use any terminal (you will not see the result in your terminal).
You need to save the downloaded content as it was suggested in post #4 and/or you can add debug info (post #6).
Also you can specify a terminal in the Exec line, something like this:
Because the launcher does not use any terminal (you will not see the result in your terminal).
You need to save the downloaded content as it was suggested in post #4 and/or you can add debug info (post #6).
Also you can specify a terminal in the Exec line, something like this:
Dont work on launcher open terminal only do nothing.
In terminal here the outputs →
$ "bash -c '/home/joao/.config/tempo.sh' "bash: bash -c '/home/joao/.config/tempo.sh' : Ficheiro ou directoria inexistente
$ bash -c '/home/joao/.config/tempo.sh'
Weather report: chaves ... → works fine
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.