LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   I created a launcher for a bash(sh) script but it won't run (https://www.linuxquestions.org/questions/ubuntu-63/i-created-a-launcher-for-a-bash-sh-script-but-it-wont-run-4175411538/)

p3aul 06-14-2012 10:34 PM

I created a launcher for a bash(sh) script but it won't run
 
1 Attachment(s)
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:

Skaperen 06-15-2012 12:02 AM

Quote:

Originally Posted by p3aul (Post 4703692)
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?

knudfl 06-15-2012 02:08 AM

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.

.

p3aul 06-15-2012 02:09 AM

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"


p3aul 06-15-2012 02:48 AM

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 :(

knudfl 06-15-2012 03:58 AM

2 Attachment(s)
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.
.

j0nn0 06-15-2012 07:44 AM

Hi

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).

Just a thought.

j0nn0

knudfl 06-15-2012 08:37 AM

# 7

That's right, the command in the desktop entry should then be e.g. :

xterm -exec audible.sh

p3aul 06-15-2012 09:14 AM

Ok that worked, but it's not saving my output file to the current directory. Is there an option for that?

knudfl 06-15-2012 09:52 AM

# 9

May be change : ffmpeg -i "$I" -vn -f wav "$O"

To : ffmpeg -i "$I" -vn -f wav "$O" > <path-to-"save"-directory>/
Like : ffmpeg -i "$I" -vn -f wav "$O" > /home/owner/folder1/


.

p3aul 06-15-2012 09:56 AM

Quote:

Originally Posted by knudfl (Post 4704092)
# 9

May change : ffmpeg -i "$I" -vn -f wav "$O"

To : ffmpeg -i "$I" -vn -f wav "$O" > <path-to-"save"-directory>/
Like : ffmpeg -i "$I" -vn -f wav "$O" > /home/owner/folder1/


.

Ok then I would always have to save in same folder.Is there a way to stipulate the current folder?

p3aul 06-15-2012 09:41 PM

hmmm...OK, I guess not

knudfl 06-16-2012 03:49 AM

The current directory . Is one period ( . )


ffmpeg -i "$I" -vn -f wav "$O" > ./

Or just : ffmpeg -i "$I" -vn -f wav "$O" > .



.

p3aul 06-16-2012 03:56 AM

Quote:

ffmpeg -i "$I" -vn -f wav "$O" > ./
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:
Code:

ffmpeg -i < ./ "$I" -vn -f wav "$O" > ./

knudfl 06-16-2012 04:06 AM

Quote:

I take it the ">" means to output it to the current dir
No. ' > ' will redirect to any directory with your write permissions.

> . : The current directory. Repeat: the dot, period ( . ) is the current directory.
> /home/owner/folder1/ : Another directory.


All times are GMT -5. The time now is 02:59 AM.