You are not logged in.

#1 2009-04-12 11:46:10

jai134
Member
Registered: 2008-11-26
Posts: 234

Making a script

Hello. Is there someone who can help me with this. I have pulseaudio up and running. I have a module for streaming music to my airport express. That is OK. I'm loading it with a script. If I want to unload that module I use "pactl unload-module" followed with the number of the module. That can be done once. If I load it again it gets another number so I can't write a script with "pactl unload-module <number>"  I have this command to get the information about the module. pactl list | grep -B1 module-raop-sink | cut -d "" -f 3. Is it possible to tell my unload-script to use that information?

Offline

#2 2009-04-12 11:59:16

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Making a script

I don't have pulseaudio so I can't test this, but assuming the second command you posted returns only the number you could do this:

pactl unload-module `pactl list | grep -B1 module-raop-sink | cut -d "" -f 3`

Or:

number=`pactl list | grep -B1 module-raop-sink | cut -d "" -f 3`
pactl unload-module $number

Offline

#3 2009-04-12 12:03:57

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Making a script

Yep, it is called 'Command Substitution' look it up on man bash.

Or info. What is a good way to use info, I had to use
info bash Basic "shell expansion" "command substitution"

Offline

#4 2009-04-12 12:40:57

jai134
Member
Registered: 2008-11-26
Posts: 234

Re: Making a script

Thankyou for your reply but the output is more. It is
Module #16
        Name: module-raop-sink
--
        Description: RAOP sink '10.0.1.2'
        Driver: module-raop-sink.c
--
        Description: Monitor of RAOP sink '10.0.1.2'
        Driver: module-raop-sink.c

Offline

#5 2009-04-12 13:05:47

jai134
Member
Registered: 2008-11-26
Posts: 234

Re: Making a script

With this I think I'm getting closer:
pactl list | grep -B1 module-raop-sink | cut -b 9-

The output then gives me
16
odule-raop-sink

tion: RAOP sink '10.0.1.2'
module-raop-sink.c

tion: Monitor of RAOP sink '10.0.1.2'
module-raop-sink.c

How do I get rid of everything below 16?

Offline

#6 2009-04-12 13:13:43

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Making a script

EDIT: Mis-read the previous post

Just dive in here: http://tldp.org/LDP/abs/html/index.html wink

Last edited by moljac024 (2009-04-12 13:26:37)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#7 2009-04-12 13:24:08

putte_xvi
Member
From: Sweden
Registered: 2009-04-10
Posts: 22

Re: Making a script

Pipe it to head -n to get the first n lines.

Or you can do it like this:

pactl list | grep -B1 "Name: module-raop-sink" | grep "Module #" | cut -d "#" -f 2

Offline

#8 2009-04-12 17:20:29

jai134
Member
Registered: 2008-11-26
Posts: 234

Re: Making a script

Thankyou. That line gave me the number. Now I have to learn the rest.

Offline

Board footer

Powered by FluxBB