Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-01-2012, 12:34 PM   #1
sumeet inani
Registered: Oct 2008
Posts: 908
Blog Entries: 26

Rep: Reputation: 49
run same command again and again

I am using tiny core.
I wanted to set all audio controls to 100
I ran
$ossmix | grep -i 'leftvol' | sed -n 's/ .*//p' | tail -n +3 | xargs ./script-to-set-all-audio-controls-to-100.txt
The script file has
echo good
ossmix "$1" 100:100
I get the feeling that the output passed to script is a long list of all controls as a result only first option gets set
The output I get is
Value of mixer control jack.jack1c.pcm3 set to 100.0:100.0
ossmix gives output
 Selected mixer 0/High Definition Audio 0x11060397
Known controls are:
jack.jack1c.mute ON|OFF (currently OFF)
jack.jack1c.pcm11 [<leftvol>:<rightvol>] (currently 62.9:62.9 dB)
jack.jack1c.pcm12 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1c.pcm3 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1c.pcm2 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1c.jack6 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1c.jack5 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1c.pcm4 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
jack.jack1d.mute ON|OFF (currently OFF)
jack.jack1e.mute ON|OFF (currently OFF)
record.select1.select1 <pcm3|pcm2|jack6|jack5|mix> (currently pcm3)
record.select1 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
record.jack6 [<leftvol>:<rightvol>] (currently 46.4:46.4 dB)
misc.pcm2 [<leftvol>:<rightvol>] (currently 62.9:62.9 dB)
misc.mute1 ON|OFF (currently OFF)
misc.pcm3 [<leftvol>:<rightvol>] (currently 62.9:62.9 dB)
misc.pcm4 [<leftvol>:<rightvol>] (currently 62.9:62.9 dB)
misc.mute2 ON|OFF (currently OFF)
misc.mute3 ON|OFF (currently OFF)
vmix0-enable ON|OFF (currently OFF)
vmix0-rate <decimal value> (currently 48000) (Read-only)
vmix0-channels <Stereo|Multich> (currently Stereo)
vmix0-src <Fast|High|OFF> (currently OFF)
vmix0-outvol <monovol> (currently 25.0 dB)
vmix0-invol <monovol> (currently 25.0 dB)
vmix0.pcm7 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm8 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm9 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm10 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
Old 09-01-2012, 12:39 PM   #2
sumeet inani
Registered: Oct 2008
Posts: 908

Original Poster
Blog Entries: 26

Rep: Reputation: 49
Seems I found the solution

ossmix | grep -i 'leftvol' | sed -n 's/ .*//p' | tail -n +3 | xargs -n 1 ./script-to-set-all-audio-controls-to-100.txt

'xargs echo' told me that all 'audio options' had been separated by space and passed as one line .
So , i saw xargs help which told :-
-n N Pass no more than N args to PROG
Old 09-02-2012, 01:04 AM   #3
sumeet inani
Registered: Oct 2008
Posts: 908

Original Poster
Blog Entries: 26

Rep: Reputation: 49
see ahead

Last edited by sumeet inani; 09-02-2012 at 01:11 AM. Reason: duplicate
Old 09-02-2012, 01:10 AM   #4
sumeet inani
Registered: Oct 2008
Posts: 908

Original Poster
Blog Entries: 26

Rep: Reputation: 49
Not Yet .
IS there a way I can write a script which takes output of "ossmix | grep -i 'leftvol' | grep -v 'known' | grep -v 'selected'| sed -n 's/ .*//p' " and apply command 'ossmix line1 100:100' 'ossmix line2 100:100' so on ..
Note: xargs I have on my tiny core is short of function (I think) because
Usage: xargs [OPTIONS] [PROG ARGS]

Run PROG on every item given by stdin

-p Ask user whether to run each command
-r Don't run command if input is empty
-0 Input is separated by NUL characters
-t Print the command on stderr before execution
-e[STR] STR stops input processing
-n N Pass no more than N args to PROG
-s N Pass command line of no more than N bytes
-x Exit if size is exceeded


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] run ps|grep command by script/command line ... ERROR: Unsupported option (BSD syntax) masuch Programming 4 05-23-2012 05:13 AM
how to run linux command from a different user from a jsp page which is run by tomcat etika Linux - Newbie 2 04-27-2011 12:53 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 12:21 PM
How to enter graphical mode (run level 5) command line (run lenel 3) edmondgyampoh Linux - Newbie 3 05-15-2009 07:33 PM
trying to fix xwindows or just run command line... changing run levels dave247 Debian 2 11-18-2008 07:11 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 PM.

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