I created a launcher for a bash(sh) script but it won't run
UbuntuThis forum is for the discussion of Ubuntu Linux.
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.
I created a launcher for a bash(sh) script but it won't run
I created a script to to pass two file names to ffmpeg in order to extract the audio from the video: The script works fine and I usually run it from a directory were I have a flv file I want to strip the audio from. It places the audio created in the same directory as the flv file. I wanted to be able to run it from the top panel in gnome 2 so I created a link and drug it to the panel. Now when I click on it it wont run. I get this error:
I created a script to to pass two file names to ffmpeg in order to extract the audio from the video: The script works fine and I usually run it from a directory were I have a flv file I want to strip the audio from. It places the audio created in the same directory as the flv file. I wanted to be able to run it from the top panel in gnome 2 so I created a link and drug it to the panel. Now when I click on it it wont run. I get this error:
Does that notice give the correct file name, even with an upper case "L" for "Link"? Does that file exist if you check for it in a terminal shell?
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
Quote:
the top panel in gnome 2 so I created a link and drug it to the panel
1) make the script.sh executable
2) cp script.sh /usr/local/bin/
3) Create a launcher that says : Exec=script.sh
3a) When the launcher / the executable works,
then an entry can be added to the panel.
I never paid any attention to that path! Maybe Ubuntu is choking on the name of the link. When I right-clicked my expresswv.sh file and chose create link that's the name it gave me, with the capital L but the full name of it was "Link to extractwv.sh" I wonder if that's all the error msg had room for or if i maybe should have renamed the link to just one word?
Well, I renamed the link and I didn't get the error msg but it didn't open the terminal window either.
Here is another one I have for temperature that I have placed under the Applications menu. It opens a terminal window and works just fine. I will list it and then mine for comparison: This the temperature converter. It is just sits in the home dir.
Code:
#!/bin/bash
echo "*** Converting between the different temperature scales ***"
echo "1. Convert Celsius temperature into Fahrenheit"
echo "2. Convert Fahrenheit temperatures into Celsius"
echo -n "Select your choice (1-2) : "
read choice
if [ $choice -eq 1 ]
then
echo -n "Enter temperature (C) : "
read tc
# formula Tf=(9/5)*Tc+32
tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
echo "$tc C = $tf F"
elif [ $choice -eq 2 ]
then
echo -n "Enter temperature (F) : "
read tf
# formula Tc=(5/9)*(Tf-32)
tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
echo "$tf = $tc"
else
echo "Please select 1 or 2 only"
exit 1
fi
echo -n "
--> Press any key to exit "
read echoice
exit 0
This is my audio extractor: I was told to put it in a directory I created call bin in the home dir so that it would be in the path statement.
Code:
#!/bin/sh
echo Enter full input file name;
read I
echo Enter full output file name;
read O
ffmpeg -i "$I" -vn -f wav "$O"
Knudfl:
I logged in as root so that I could copy the file extractwv.sh to user/bin/ like you said. I created a file called audible.sh with the code you gave me and converted it to a launcher by dragging it to the panel(thats the only way I know how to do it) I get no error msgs when I click on it, but it doesn't work either
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
Quote:
a file called audible.sh .. .. and converted it to a launcher
by dragging it to the panel
Not possible.
Please copy your scripts to /usr/local/bin/ :
1) chmod +x expresswv.sh
2) chmod +x audible.sh
3) sudo cp expresswv.sh /usr/local/bin/
4) sudo cp audible.sh /usr/local/bin/
... First then you can get a launcher to use the scripts.
Which OS are you using ? Like Ubuntu 12.04.
Which Desktop is it about ? KDE, Gnome 3, Gnome 2. Please specify.
A launcher is a short text file. Named a desktop entry : Name.desktop.
All Desktops have a tool to automatically create a launcher. (Gnome 3 : Don't know.)
Two examples are attached.
.
Don't have my laptop with me now, but just an observation:
Your scripts require the user to make input in a terminal. To make a shell script run in a terminal, doesn't one have to tell the launcher explicitly to run it in a terminal? Otherwise it just runs in the background, waiting for input, like the little android boy in "AI". I seem to remember in KDE anyway there is a check-box for "Run in Terminal" or something (in the Properties).
Yeah that sounds good I take it the ">" means to output it to the current dir. What about the input? How will ffmpeg find the input file? Would < work for input like:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.