LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 06-14-2012, 10:34 PM   #1
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Rep: Reputation: Disabled
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:
Attached Thumbnails
Click image for larger version

Name:	Screenshot-1.png
Views:	41
Size:	13.3 KB
ID:	9895  
 
Old 06-15-2012, 12:02 AM   #2
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by p3aul View Post
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?
 
Old 06-15-2012, 02:08 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.

.
 
Old 06-15-2012, 02:09 AM   #4
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
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"

Last edited by p3aul; 06-15-2012 at 02:23 AM.
 
Old 06-15-2012, 02:48 AM   #5
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
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
 
Old 06-15-2012, 03:58 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.
.
Attached Files
File Type: txt audible2.desktop.txt (159 Bytes, 18 views)
File Type: txt audible1.desktop.txt (186 Bytes, 14 views)

Last edited by knudfl; 06-15-2012 at 04:02 AM.
 
Old 06-15-2012, 07:44 AM   #7
j0nn0
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Rep: Reputation: 1
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
 
1 members found this post helpful.
Old 06-15-2012, 08:37 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 7

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

xterm -exec audible.sh
 
Old 06-15-2012, 09:14 AM   #9
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

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

Last edited by p3aul; 06-15-2012 at 09:25 AM.
 
Old 06-15-2012, 09:52 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 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/


.

Last edited by knudfl; 06-16-2012 at 03:46 AM.
 
Old 06-15-2012, 09:56 AM   #11
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
# 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?
 
Old 06-15-2012, 09:41 PM   #12
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
hmmm...OK, I guess not
 
Old 06-16-2012, 03:49 AM   #13
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The current directory . Is one period ( . )


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

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



.

Last edited by knudfl; 06-16-2012 at 03:54 AM.
 
Old 06-16-2012, 03:56 AM   #14
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
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" > ./
 
Old 06-16-2012, 04:06 AM   #15
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sshfs in bash script - won't run in called terminal? basd Linux - General 3 03-17-2012 05:10 PM
bash script - get filename created by script using variables aolong Linux - General 8 11-19-2009 12:40 PM
[SOLVED] Bash script with environment variables -Application launcher Offman Linux - Newbie 14 07-15-2009 01:21 PM
gnome launcher won't run a sudo command directly or via a script gnreeke Linux - Desktop 1 06-23-2009 10:44 AM
How do I create application launcher using bash script msgclb Programming 2 01-30-2005 06:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 02:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration