LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-20-2012, 11:14 PM   #1
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Rep: Reputation: Disabled
I placed a script in the scripts folder to record music . This works fine but....


Ubunto 10.04 Gnome 2 nautilus.

First of all the script works fine in the terminal. The recording stops when I press CTRL-C or close the window. If I right-click in a folder and run the script, the file is created in that folder and the file size keeps increasing so I know it is recording. The problem is since there is no terminal to close and pressing Ctrl-C doesn't work I don't know how to stop the script when the music ends.

Any help please?
 
Old 02-21-2012, 12:19 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you can use the the ps command to look up the process id, and then use the kill command to kill the corresponding process. There are also commands like pkill and killall that you may want to investigate.

HTH,

Evo2.
 
Old 02-21-2012, 08:45 AM   #3
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
hmm the cure seems almost as painful as the problem. I will post the script which I ot from someone here, I forget who. Maybe some one could figure out how to stop it. I have another script which I was able to put in the application menu that converts temperatures from one scale to another. This had a menu and was straight-forward and easy to understand. This script refers to stuff I don't know much about. anyway here is the script:

Code:
#!/bin/bash
# Copyright 2008-2009, Kees Cook <kees@outflux.net>
#
# Records the PulseAudio monitor channel.
# http://www.outflux.net/blog/archives/2009/04/19/recording-from-pulseaudio/
#
#This script require sox
#sudo apt-get install sox

if [ -n "$1" ]; then
    OUTFILE="$1"
else
    TIME=$(date +%d-%b-%y_%H%M-%Z)
    OUTFILE="recording_$TIME.wav"
fi

# Get sink monitor:
MONITOR=$(pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)

# Record it raw, and convert to a wav
echo "Recording. Ctrl-C or close window to stop"
parec -d "$MONITOR" | sox -t raw -r 44100 -sLb 16 -c 2 - "$OUTFILE"

# End of soundcap.sh
 
Old 02-21-2012, 01:17 PM   #4
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
Can someone please help
 
Old 02-21-2012, 08:14 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

I've told you how to kill a process. What exactly is the problem?

Evo2.
 
Old 02-22-2012, 06:06 AM   #6
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
I *know* how to "kill" the process. I can do that by running terminal and doing a ctrl-c. I wanted something more elegant. I tried a read command at the end of the script but that didn't do it. What I wanted was when I clicked on the script, after I put in the applications menu, for the script to open in terminal and wait there for to to either press a key or type ctrl c. Here is a simple script that illustrates what I want to do.

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 "
I tried "read choice" like they did to hold the window open but it didn't work
 
Old 02-22-2012, 06:53 PM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by p3aul View Post
What I wanted was when I clicked on the script, after I put in the applications menu, for the script to open in terminal and wait there for to to either press a key or type ctrl c.
Ahh, in that case you should modify what happens when you "click on the script". Instead of running the script directly, try something like:
Code:
xterm -e script.sh
Evo2.
 
Old 02-23-2012, 01:51 AM   #8
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
Thanks for the reply. should:

Code:
xterm -e script.sh
be in a script by itself and will that command call the script "script.sh" which, I assume is my sound capture script?

Thanks,
Paul
 
Old 02-23-2012, 09:53 PM   #9
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by p3aul View Post
Thanks for the reply. should:

Code:
xterm -e script.sh
be in a script by itself
You may be able to just put that exact line in place of the script you were previously running.
If that doesn't work try putting the above line in a script of it own.

Quote:
and will that command call the script "script.sh" which, I assume is my sound capture script?
Yes. Check the man page for xterm to understand what the -e option does. You man also be interested in -T and -n.

Evo2.
 
  


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
Scripts to list folder contents and copy images from folder and subfolders brunces Linux - Newbie 6 11-03-2011 01:23 PM
Perl disc maintenance script for Windows - works fine could be improved justinjoseph24 Programming 8 03-24-2008 10:14 PM
Mounting works, playing music works, reading tags doesn't Celettu Linux - Newbie 7 08-23-2006 12:27 PM
audacity. can record once fine, but then the sound goes weird jimjamjahaa Linux - Software 2 01-20-2006 06:06 AM
Launch Yahoo Music Videos Script No Longer Works mfeat Linux - Software 6 11-01-2005 05:55 PM

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

All times are GMT -5. The time now is 07: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