Setting volume automatically in shell script

hi there, I'm trying to create a shell script that unmutes and sets the volume for a sound card's mixer controls, using amixer.  It will pretty much always be run in Arch Linux using alsautils.  This script will be used on computers where I won't necessarily know what exact controls the user will have in their sound card, so running a command like 'amixer set Master unmute 75%' won't really work, but they may not have a Master, or it might have a slightly different name.  So really it seems like the only way to get this done is to parse through the output of 'amixer scontrols' and try to find all controls that have either a pvolume or cvolume capability.  Is this the best way of doing this, or is there some simpler way?  If so, I was hoping people could give me a headstart on the sed/awk pattern(s) I'll need for this.
Thanks all

Not sure what you're asking but:
amixer scontrols | sed "s#^.*[']\(.*\)['].*#\1#"
returns a list of all available controls... or did you only want to find a way to test whether a control is c/p-vulume capable. Is that one always on top  maybe?
My suggestion would be to try aumix... it's in comunity as "aumix-gtk"...
then you can simply use:
#voldown
aumix -v -10
#volup
aumix -v +10
If this doesn't help you, could you be more specific?

Similar Messages

  • Oracle 11g R1 Automatic Installation shell scripts

    Hy Guys,
    Please can someone help me with: Oracle 11g R1 Automatic Installation shell scripts. A guide, how to or a link will be wellcome
    Kind Regards
    Easyman
    Edited by: Easyman on Feb 2, 2010 3:58 AM

    Hi Easyman,
    sure, just have a look in $INSTALL_CONF directory. Files starting with swInst* are referencing a response file from $INSTALL_CONF/response directory. Either use a sample configuration file or add your own response file to install Oracle.
    Cheers,
    David
    OCP 9i / 10g / 11g
    http://www.oratoolkit.ch/knowledge/howto/installation/otn.php
    P.S.: If you have more questions about oraToolKit please contact me at: http://www.oratoolkit.ch/faq.php

  • BI Admin Tool - Setting connection pool via shell script - Is it possible?

    Hi,
    Here's the problem I am trying to solve.
    I am using a J2EE application that uses OBIEE for reporting.
    The *.rpd file is installed at a particular location when our J2EE product is installed.
    I then copy the *.rpd file to the BI home on a different server using a shell script.
    The shell script that deploys the *.rpd file does the following:
    1. Shuts down BI processes that are running
    2. Deletes the old *.rpd file
    3. Copies the new *.rpd file
    4. Starts all BI processes
    I am happy with the way we have automated this process, but would like to take it one step further.
    The *.rpd file does not have the connection pool hard-coded in it. And we want to keep it that way.
    What we would like to do is - pass the connection pool parameters to the shell script (that is used for *.rpd's deployment) and have it automatically update the *.rpd file. Is it possible to do this at all? How do we go about accomplishing this?
    Or in other words - Is there a way to update the connection pools WITHOUT hard-coding it in the *.rpd file or WITHOUT using the BI Administration Tool.
    Currently, we manually update the connection pools in the Physical Layer using the Oracle BI Administration Tool.
    The version of BI Administration Tool being used is 10.1.3.3.1 installed on a Microsoft Windows XP Professional SP2 machine. The BI Server itself is running on an Oracle Enterprise Linux 4.0 box.
    Do let me know if you need more information that would help answer this question.
    Thank you.

    Thank you - fiston and Gagan.
    I am going with fiston's solution - since it is easier to implement. I am on the QA team and the automated deployment is to lessen QA's deployment time.
    While one of our developer's said that she prefer's Gagan's solution - it would be over-kill to make changes to the application's schema for the said purpose.
    I will further make another post as to whether or not the automated deployment worked for us.

  • Executing set of procedures from Shell script.

    Hi,
    I've set of procedures which i need to pass a parameter from the os ..like this.
    For table XXX ...i need to call
    a Procedure XXX ('parameter as file name ')..
    So i've a test.sql file which is calling
    EXEC XXX(&1);
    The Shell script file will be like this...
    sqlplus username/password @test.sql
    Like this i need to call 10 tbles.
    so 10 sql file and 10 shell script file.
    And also i need to scedhule the *.sh file.
    Is that a right way ....? or any other method to achive this ????
    IT'S URGENT...
    Thanks

    Hi,
    Make a file proc.txt containing the name of the proc :
    proc1
    proc2
    proc3
    A second file for the tables names tables.txt containing :
    table1
    table2
    table3
    And the shell will be :
    #!/bin/bash
    TAB=tab.txt
    PROC=proc.txt
    for THE_TABLE in `cat $TAB`
    do
    for THE_PROC in `cat $PROC`
    do
    sqlplus system/manager <<!
    exec $THE_PROC ;
    exit ;
    done
    done
    Fred
    ~
    ~

  • Automatically run shell script after publishing?

    Is there any way to automatically run a  shell script  after publishing?
    I would like to do some postprocessing on the remote server.
    The remote server is not mobileme,  so a tool like iwebenhancer  will not work.
    I will appreciate all kinds of tips and tricks and suggestions.
    best regards, Gabriel.

    So the Detect Change is to detect a change in the web page that the code is embedded, right?
    The only workaround would be, if you can modify what's in the ChangeDetection window is to not automatically enter the page but put in a red note to enter the page you want to be notified about.
    So instead of this:
    You would have this:
    where the visitor would have to copy and past the URL into the field.  Obviously not automatic. But might work if you can modify what is said in the window and not have the page automatically be entered.

  • Setting a variable from the output of a shell script

    I would like to use the output of the shell script "pwd" to populate a variable that I will then use to concatenate the argument to another shell script.
    Below is what I tried, but that didn't work.
    Any help is greatly appreciated.
    set currentDir to do shell script "pwd"
    do shell script "open " & currentDir & "/somedir/somefile"

    Does an applescript always run from "/" or from the directory in which the applescript file is run?
    From: http://developer.apple.com/technotes/tn2002/tn2065.html :
    Q: What’s the default working directory for do shell script commands?
    A: do shell script inherits the working directory of its parent process. For most applications, such as Script Editor, this is /. For osascript, it’s the working directory of the shell when you launched osascript. You should not rely on the default working directory being anything in particular. If you need the working directory to be someplace specific, set it to that yourself.

  • Syntax for inserting a number in a shell script in applescript

    who can help me correct this code?
    the user will enter a number in a dialog box, and this variable will replace the 7 in the shell script.
    i cant seem to keep the syntax right, i keep erroring out.
    if days_back is "" then
    set dialog_1 to display dialog "please enter a number " default answer ""
    set the days_back to the text returned of dialog_1
    end if
    set the_result to (do shell script "mdfind -onlyin '/Volumes/Volume1' 'kMDItemFSContentChangeDate >=$time.today(-7)'")
    display dialog the_result

    Try using:
    if days_back is "" then
    set dialog_1 to display dialog "please enter a number " default answer ""
    set the days_back to the text returned of dialog_1
    end if
    do shell script ("mdfind -onlyin '/Volumes/Volume1' 'kMDItemFSContentChangeDate >=$time.today(-" & days_back & ")'")
    display dialog the result
    (54186)

  • Add Password to Shell Script for ssh

    Hi I'm trying to avoid creating ssh keys for this I was hoping to write it all in to applescript.
    This is what I have.
    I've done lots of searches, but not quite getting the right outcome.
    Matt
    set ShellS to "rsync -aE --progress --delete --exclude=\"._*\" /Volumes/Images/2014-2015 [email protected]:/Volumes/ImagesB/ "
    do shell script ShellS

    Thanks, that did help, I wondered what all those extra files were,
    Now searching the net this is where I am at., But I get the error
    error "invalid command name \"rsync\"
        while executing
    \"rsync -a --progress --delete --exclude=\"._*\" -e ssh /Volumes/Images/2014-2015 [email protected]:/Volumes/ImagesB/ \"" number 1
    set sshPasswd to "PSW"
    set ShellS to "rsync -a --progress --delete --exclude=\"._*\" -e ssh /Volumes/Images/2014-2015 [email protected]:/Volumes/ImagesB/
    expect {
      \"Password:\" {
          send \"" & sshPasswd & "\\r\"
          exp_continue
        \"yes/no?\" {
          send \"yes\\r\"
          exp_continue
    do shell script "expect <<<" & quoted form of ShellS

  • Shell script to mount/unmount Vista laptop samba shares?

    I have a couple Vista laptops in the house that I take to the office regularly, and currently I use Dolphin to browse into the laptop and xfer files back and forth, but I really don't want to use dolphin, I'd rather set up some kind of script/alias that can prompt me to mount and unmount the share instantly in shell, instead. Is this possible or do I just have to do it in fstab and issue mount/unmount commands everytime?
    TIA for any help

    I tested on a USB stick, no probs, I put my USB stick in a slot, waited for it to mount, ran the script using the "unmount first", then ran the "mount" second worked fine after that using the "unmount " part of the script, I found though that if I right clicked "eject" that the script would not mount the volume.
    You could try something as simple as the below maybe.
    tell application "Finder"
    eject "LEXAR MEDIA"
    end tell
    set _VolumeName to "LEXAR MEDIA"
    set deviceName to do shell script "diskutil list | grep \"" & _VolumeName & "\" | awk '{print $6}'"
    --do shell script "diskutil mountDisk /dev/" & deviceName --mount
    do shell script "diskutil unmountDisk /dev/" & deviceName --unmount
    Budgie

  • Problem with backtick replacing apostroph in applescript/shell script

    I've got a script that appears to be using a backtick instead of an apostrophe which is causing an error in my shell script. For the life of me I can't seem to find where the error is being generated?
    The script is attached below. I'm using Exiftool, an app that writes metadata to image files. The shell script
    set cmd to "exiftool -CopyrightNotice=" & exifCopyright & " " & thisFilePath & ""
    set theResult to do shell script cmd
    works fine but the following shell script
    set cmd to "exiftool" & space & authorStr & " " & thisFilePath & ""
    set theResult to do shell script cmd
    returns the error "sh: -c: line 0: unexpected EOF while looking for matching `''
    sh: -c: line 1: syntax error: unexpected end of file" number 2. The code in the event log in applescript editor looks exactly the same to me but one fails in the shell script.
    It has been suggested by the developer of Exiftool, Phil Harvey, that there is a backtick in the second shell script. I read somewhere in the applescript docs that this is due to a change in OS 10.6? Any suggestions on how to fix this?
    Thanks.
    Pedro

    Yea, the authorStr value has a space like "Joe Smith"
    Then you need to use quoted form of this string, too:
    set cmd to "exiftool " & quoted form of authorStr & space & thisFilePath
    although the format looks wrong to me - shouldn't there be some kind of switch, such as "-author=' before it?
    You have to consider how you'd enter this at the command line to work out how best to translate it to AppleScript. For example, if the command line version were:
    exiftool -author='John Doe' /path/to/some.jpg
    you can see the quotes are around the name, not the entire -author switch. In this case you should be looking at something like:
    set authorStr to "John Doe"
    set theFilePath to "/path/to/some.jpg"
    set theCmd to "exiftool -author=" & quoted form of authorStr & space & quoted form of theFilePath
    Now you could, of course, use quoted form when you create the variables (e.g. set authorStr to quoted form of "John Doe"), but that may screw you up later on if/when you try to use authorStr in some other way, so I find it best to use quoted form only where it's needed.

  • Shell script friendly paths in applescript

    I have a python script that resides inside a standalone application bundle. I run this script from the app and call it by getting the path of the application bundle and adding '/Contents/Resources/' to the path. This script sets or gets information from a plist. So, adding a ' --list' to the script name returns the items of the plist.
    This is my applescript and RWplist is the python script.
    set plInfo to do shell script "/Users/[just me]/Desktop/Test Project/Test App.app/Contents/Resources/RWplist --list'
    This fails due the the spaces in the directory and app name. If I change the folder and app name like;
    set plInfo to do shell script "/Users/[just me]/Desktop/Test-Project/Test-App.app/Contents/Resources/RWplist --list'
    This works... I tried wrapping the path in single quotes, I tried to do a replace all spaces to '\\space' in the path... and adding the 'quoted form of POSIX path of'...
    I'm guessing I'm placing the single quotes or using the quoted form... improperly. Can someone please explain how to format a path in this manor. I can't seem to find the proper syntax for this.

    This fails due the the spaces in the directory and app name
    Right, this is a common problem that many people encounter.
    I'm guessing I'm placing the single quotes or using the quoted form... improperly. Can someone please explain how to format a path in this manor.
    quoted form is the preferred/recommended way of doing this. Here's an example:
    set cmdPath to "/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist"
    do shell script (quoted form of cmdPath) & " --list"
    If you want to build the script manually then you should single-quote the entire path, e.g.:
    do shell script " '/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist' --list"
    Note that there are single quotes around the command path but the --list parameter is outside of the single-quoted path.

  • Find & replace part of a string in Numbers using do shell script in AppleScript

    Hello,
    I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
    The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
    Could anyone hand me a solution to this problem?
    The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
    Thx.

    Hi,
    Here's how to do that:
    try
        tell application "Numbers" to tell front document to tell active sheet
            tell (first table whose selection range's class is range)
                set sr to selection range
                set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
                if f = "" then return
                set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
                set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
                set tc to count cells of sr
                tell sr to repeat with i from 1 to tc
                    tell (cell i) to try
                        set oVal to formula
                        if oVal is not missing value then set value to (my find_replace(oVal, f, r))
                    end try
                end repeat
            end tell
        end tell
    on error number n
        if n = -128 then return
        display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
    end try
    on find_replace(t, f, r)
        do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
    end find_replace
    on escapeForSED(f, r)
        set tid to text item delimiters
        set text item delimiters to "*" -- the wildcard 
        set tc1 to count (text items of f)
        set tc2 to count (text items of r)
        set text item delimiters to tid
        if (tc1 - tc2) < 0 then
            display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
            error -128
        end if
        -- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
        set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
        -- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get  the back reference --> \\1 \\2
        return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
    end escapeForSED
    For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
    Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
    But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string.

  • How to pass variables to shell script?

    I have a shell script which uses the touch command to change the date of a file.  To run the command on the command line the syntax is:
    set-file-date.sh <file> <date>
    I'm trying to run it from an automator workflow, so I'm prompted for the date, then the workflow iterates over the finder items, i.e., files, and changes the date of each files.
    The problem is in the "Run Shell Script" action.  The $@ is substituted with the file names selected in finder, so this will echo the file names:
    for i in "$@"; do
         echo "$i"
    done
    What I want to do is something like this:
    for i in "$@"; do
         set-file-date.sh <DATE VARIABLE> "$i"
    done
    But I can't prompt for the date value, and pass it to the script.  I've tried using the "Get Value of Variable" and the "Ask For Text" actions.  I can either get the file names from finder OR the text input in the "Ask for Text" action, but not both.
    Is what I'm trying to do possible with a shell script?
    -Thanks

    This is standard AppleScript text concatenation...
    set howManyWords to do shell script "wc -w /path/to/file | awk '{print $1}'"
    do shell script "/usr/local/bin/growlnotify -t 'Corpus' -m '" & howManyWords & " words were added to the corpus.'"
    in other words, just use the & to concatenate the parts of your text together.

  • Exit status running java classpath in a unix shell script

    I'm new to putting java into unix scripts. I have a java classpath running inside of a unix shell script. During my testing it will error with java.io.FileNotFoundException error, which I know why that is, but when I set in my unix shell script this to see the right exit status of success/fail, it always shows a 0 for success when that isn't really the case. Below is the two lines I have set to capture the exit status and just display that exit status for now.
    notifycode=$?
    echo $notifycode
    I have these 2 lines above on a line right below my java command in my unix shell script. How can I get my unix shell script to show the right exit status if the java classpath command fails? Thanks for any help.

    That's Java code, it says "End this Java application and send return code 1 back to the shell". As for how the shell gets the return code from the application, that's a question about your shell and not about Java programming, no?

  • Check shell script status

    The following question is related to the same application I am developing in the thread named "Open something on first launch?", if that may help you answer it.
    How exactly do I check to see if hidden files are being displayed or not?
    This:
    set shellcheck to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
    if the result returned in shellcheck = FALSE then
    display dialog "FALSE"
    else if the result returned in shellcheck = TRUE then
    display dialog "TRUE"
    end if
    or this:
    set shellcheck to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
    if shellcheck = false then
    display dialog "FALSE"
    else if shellcheck = true then
    display dialog "TRUE"
    end if
    doesn't seem to work...

    The first thing to realize is that if the defaults parameter doesn't exist, the script will return an error. Therefore your code needs to include a try/end try block to catch that error.
    Secondly, if the key/value does exist, defaults will return '1' if it's true, or '0' if it's false.
    Therefore, your script should look more like:
    try
      set shellcheck to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
      if shellcheck = "0" then
        display dialog "FALSE"
      else if shellcheck = "1" then
        display dialog "TRUE"
      end if
    on error
      display dialog "Preference value does not exist"
    end try

Maybe you are looking for

  • Ultrabeat's pan mod function?

    Ultrabeat's pan mod function? Could someone please explain to me how Ultrabeat's pan mod function works? I know how to use automation in LPX's Tracks Area to automate panning but I'd like to avoid that on this occasion. I also tried using the LFO to

  • Urgent!  Details of english sort orders in SQL databases

    I need (for reasons that would take too long to explain and probably breach company security) to duplicate in Java (preferably a Comparator) the sorting order used by a SQL database. I can find lots of things telling me how to tell a database to use

  • How to highlight only one column

    I am trying to highlight and copy one column but the one next to it is also highlighted.  Help!!

  • Split and pick

    Hi Folks, I need to pick the data from a field and dispaly it as two fields.Can anyone here let me know how to go with this. addr1_data-remark:-(table is addr1_data and the field is remark). now i have to pick the contents from the field "remark" of

  • I can't move iViews in column2 or 3 inside a page

    Hello, i have the following problem: I have one page in the portal content with 3 columns. When i add a iView then is the default position column1. I can't move iViews in column2 or 3 inside a page with drag & drop. The Explorer is IE6.0. Portal is E