[Gambas-user] Obtaining Sound Output Monitor's Name
Tobias Boege
taboege at ...626...
Tue Dec 10 21:06:40 CET 2013
On Tue, 10 Dec 2013, John Rose wrote:
> I'm trying to obtain the sound output monitor's name (as a string using
> the Shell command) for later use in an Exec command (calling ffmpeg).
>
> Running the appropriate command in a Terminal gives:
> john at ...2811...:~$ pactl list | grep -A2 '^Source #' | grep 'Name:
> .*\.monitor$' | awk '{print $NF}' | tail -n1
> alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
>
> I have Gambas code for opening FMain form as:
> Dim sSoundMonitorExtractor As String
> Me.Center()
> sSoundMonitorExtractor = Shell$("pactl list | grep -A2 '^Source #' |
> grep 'Name: .*\\.monitor$' | awk '{print $NF}' | tail -n1")
> Shell sSoundMonitorExtractor To sSoundMonitor
> Print "Sound Monitor = " & sSoundMonitor
>
> I have 2 backslashes in the Shell$'s string as otherwise the compiler
> objects. When I run the Gambas executable, the Console displays:
> Sound Monitor =
> I.e. sSoundMonitor is not set. What am I doing wrong?
>
Shell$() is there to quote arguments, not entire commands. Just look at
$ gbx3 -e 'Shell$("pactl list")'
pactl\ list
so you will execute "pactl\ list" which will be interpreted by the shell as
a program named "pactl list" which is *not* the program "pactl", called with
argument "list". Shell$() is there to sanitise user input. Leave it away and
it should work (so far).
Regards,
Tobi
More information about the User
mailing list