I placed a script in the scripts folder to record music . This works fine but....
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 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.
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.
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
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
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.