Unexpected token `(' in my bash script [Solved]

I've been working on a bash script, and I'm trying to get it to move all directories that are not named certain names to another directory.
EDIT: Fixed the thing papajoke pointed out
#!/bin/bash
mv ~/Downloads/!(folders|pics|docs|code|archives|vids|sounds)/ ~/Downloads/folders/
The command from the script does what I want it to do when I run it from a terminal.
It also works if I run the script as follows:
source script.sh
It doesn't work like this:
bash script.sh
I'm trying to get it to run when I login, and using the running the command with "source" in my MATE Startup Applications doesn't work.
I'm new to bash scripting, any help would be much appreciated.  Thanks
Last edited by physicsshark (2015-04-07 20:09:07)

Trilby wrote:I've never seen that syntax
You mean the pipes or the bang?
$ touch a.gz b.gz c.txt
$ ls !(*.gz)
c.txt
This works as an alias and from the comeliness commandline, but not in a script.
$ ls -l ~/2
total 16
drwxr-xr-x 2 karol users 4096 Apr 7 03:13 a
drwxr-xr-x 2 karol users 4096 Apr 7 03:07 b
drwxr-xr-x 2 karol users 4096 Apr 7 03:07 c
drwxr-xr-x 2 karol users 4096 Apr 7 03:13 d
$ mv ~/2/!(a|b|c) ~/2/a
$ ls -l ~/2
total 12
drwxr-xr-x 3 karol users 4096 Apr 7 03:14 a
drwxr-xr-x 2 karol users 4096 Apr 7 03:07 b
drwxr-xr-x 2 karol users 4096 Apr 7 03:07 c
$ ls -l ~/2/a
total 4
drwxr-xr-x 2 karol users 4096 Apr 7 03:13 d
Last edited by karol (2015-04-07 01:20:14)

Similar Messages

  • Multiarchive RAR bash script (SOLVED)

    Dear Fellow Archies!
    I use the command
    rar a -w<working_folder> -m5 -v<max_volume_size> <archive_name> <target_file_or_folder>
    whenever I need to make a multiarchive rar file, because I have not yet found a GUI archive manager that does this.
    So, I've decided to write a simple bash script to make things easier.
    Here's the script:
    #!/bin/bash
    echo Please, enter the full path to the target file or folder [without the target itself]!
    read PATH
    echo Please, enter the target filename [with extension] or folder name!
    read TARGET
    echo Please, enter the desired archive name [without extension]!
    read DESTINATION
    echo Please, enter the desired volume size in KB!
    read SIZE
    rar a -w$PATH -m5 -v$SIZE $DESTINATION $TARGET
    Executing the last line of the code in terminal works without any hassle. When I run this entire script however, it doesn't.
    What needs to be changed for the script to work?
    RAR man page is HERE - CLICK, in case someone needs to take a look at something.
    Thank you and thank you,
    UFOKatarn
    Last edited by UFOKatarn (2012-05-03 07:38:28)

    Done! Working!
    Geniuz: Logout-login did it. How simple.
    Juster: I added "echo $PATH" to the script and ran it with "bash -x". And the output was the same as after the logout-login. Here it is, in case you are curious.
    /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl:/opt/qt/bin
    Thank you all for your help guys :bow:.
    OFFTOPIC:
    All who intend to use Xfce launchers to run bash scripts: There are two options in the settings for each launcher: "Command" and "Working Directory". And when I had "Working Directory" filled with "/home/username/", the script didn't work. It worked perfectly after I blanked out the "Working Directory" option. Just so you know, in case someone doesn't .
    This has never happened to be before, but still, I guess it is better to do it with blank "Working Directory" and entering the entire path into the script in the "Command" field. It might be that Xfce launchers always stick to the "Working Directory", even though a script might tell them otherwise.
    Last edited by UFOKatarn (2012-05-03 07:38:05)

  • [solved] Running a command in background (bash script)

    Salut,
    as netcfg2 does not work with my wireless connection, I have to set up the connection manually. For not having to type in the commands every time, I created a bash script.
    #!/bin/bash
    iwconfig wlan0 mode managed essid mynetwork channel 6
    ifconfig wlan0 up
    wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant.conf -dddd &
    dhcpd wlan0
    This works fine till the wpa_supplicant line. wpa_supplicant is not started in the background (as I thought, the ampersand at the end of the line would.
    So how can I get wpa_supplicant run in the background?
    Thanks in advance,
    Stefan
    Last edited by vbtricks (2008-05-11 09:13:36)

    Ramses de Norre wrote:How do you know it isn't? What exactly does happen?
    The script does not return to the user-prompt. Is an ampersand at the end of the line the correct solution, or are you unsure yourself?
    bender02 wrote:On thing is that even if it starts, it does take it a couple of seconds to connect, so it's probably not very good to run dhcpcd right after wpa_supplicant. Another thing is that you probably have a typo up there, shouldn't it be 'dhcpcd' instead of 'dhcpd'?
    Well, as the wpa_supplication command is not really run in the background the script did never execute the dhcpcd command. After having solved the above, correcting the spell-mistake will be a smaller problem. Even calling the dhcpcd command myself would be no unworkable way, the open root-shell (as I have to use another as the one calling the script is blocked) is a far greater problem...

  • [SOLVED] problem with spaces and ls command in bash script

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble:
    HOMEDIR="/home/panos/Web Site"
    for file in $(find "$HOMEDIR" -type f)
    do
    if [ "$(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)")" -gt 30 ];
    then echo -e "File $file is $(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)") old\r" >> /home/panos/scripts/temp;
    fi
    done
    The dateDiff() function is defined earlier and the script works fine when I change the HOMEDIR variable to a path where there are no spaces in directory and file names. I have isolated the problem to the ls command, so a simpler code sample that also doesn't work correctly with path names with spaces is this:
    #!/bin/bash
    HOMEDIR="/home/panos/test dir"
    for file in $(find "$HOMEDIR" -type f)
    do
    ls -lh "$file"
    done
    TIA
    Last edited by panosk (2009-11-08 21:55:31)

    oops, brain fart. *flushes with embarrassment*
    -- Edit --
    BTW, for this kind of thing, I usually do something like:
    find "$HOMEDIR" -type f | while read file ; do something with "$file" ; done
    Or put those in an array:
    IFS=$'\n' ; files=($(find "$HOMEDIR" -type f)) ; unset IFS
    for file in "${files[@]}" ; do something with "$file" ; done
    The later method is useful when elements of "${files[@]}" will be used multiple times across the script.
    Last edited by lolilolicon (2009-11-09 08:13:07)

  • Simple bash script to add a '-' [Solved]

    I need to write a small bash script to add a '-' to each line in a file before displaying via conky!
    Todo
    - Get Milk
    - Buy Food
    - Pay Bills
    Currently I use
    TEXT
    Todo
    ${hr}
    ${head /home/mrgreen/.stuffigottado.txt 30 20}
    In .conkyrc but have to add '-' each time I edit .stuffigottado.txt
    Thanks in advance....

    Cerebral wrote:
    To filter out blank lines, you could just modify the awk command:
    ${exec awk '!/^$/ { print "-", $_ }' stuffigottado.txt}
    very nice; awk and grep: two commands that never cease to amaze me.

  • [solved] Segmentation fault with bash script

    I have a bash script that checks if it has to do something, if not it sleeps 15 secs and checks again. It works great except that after ~6hrs of just checking and sleeping it seg faults. I upped the stack limit with ulimit -s and it goes ~12hrs before it seg faults. I have a similar script that I have been using for ages that works for 24hrs no problem and I can't pinpoint where the problem is.
    The check it does is to see if a file exists, if it's empty and if not, read the first line of a file and do some date comparisons. It doesn't matter if the file is empty or not the seg fault always happens.
    Here's the seg fault causing script - it starts at the bottom
    #!/bin/bash
    # User defines
    declare -i DVB_DEVICE_NUM="0"
    declare CHANNELS_CONF="${HOME}/Mychannels.conf"
    declare SAVE_FOLDER="${HOME}/TV/tele"
    declare SCHED_FILE="$HOME/.sched-tv"
    declare ZAP_COMMAND="tzap"
    declare -i SLEEP=15
    # Program defines
    declare -i DAY="0"
    declare -i START="0"
    declare -i FINISH="0"
    declare CHAN="0"
    declare NAME="0"
    declare -i MINUTES="0"
    declare -i REC_START="0"
    declare -i REC_HOURS="0"
    declare -i REC_MINS="0"
    declare -i howlong="0"
    declare -i PIDOF_AZAP=0
    declare -i PIDOF_CAT=0
    red='\033[1;31m'
    green='\033[1;32m'
    yell='\033[1;33m'
    cyan='\033[1;36m'
    white='\033[1;37m'
    reset='\033[0m'
    function remove_entry {
    if [ "$NAME" == "" ]; then
    sed "/$DAY $START $FINISH $CHAN/d" $SCHED_FILE > /tmp/dummy
    else
    sed "/$DAY $START $FINISH $CHAN $NAME/d" $SCHED_FILE > /tmp/dummy
    fi
    mv /tmp/dummy $SCHED_FILE
    function record_entry {
    ${ZAP_COMMAND} -a ${DVB_DEVICE_NUM} -f ${DVB_DEVICE_NUM} -d ${DVB_DEVICE_NUM} \
    -c $CHANNELS_CONF -r ${CHAN} >/dev/null 2>&1 &
    PIDOF_AZAP=$!
    if [ "$PIDOF_AZAP" == "" ]; then
    printf "$red\tError starting ${ZAP_COMMAND}.\n\tFAILED: $CHAN $START\n"
    remove_entry
    exit 1
    fi
    printf "$green\tSET CHANNEL$cyan ${CHAN}\n"
    REC_MINS=$((${START}%100))
    REC_HOURS=0
    MINUTES=0
    REC_START=$(($START-$REC_MINS))
    while [ $((${REC_START}+${REC_HOURS}+${REC_MINS})) -lt $FINISH ]; do
    ((REC_MINS++))
    ((MINUTES++))
    if [ ${REC_MINS} -ge 60 ]; then
    REC_MINS=0
    ((REC_HOURS+=100))
    fi
    done
    if [ "$NAME" == "" ]; then
    declare FILE_NAME="${SAVE_FOLDER}/TV-`date +%Y%m%d-%H%M`-ch.${CHAN}-${MINUTES}.min.mpg"
    else
    declare FILE_NAME="${SAVE_FOLDER}/TV-${NAME}-${MINUTES}.min.mpg"
    fi
    dd if=/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} \
    of=${FILE_NAME} conv=noerror &
    PIDOF_CAT=$!
    if (( ${PIDOF_CAT} == 0 )); then
    printf "$red\tError Starting Recording.\n\t/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} Unavailable\n"
    kill ${PIDOF_AZAP}
    remove_entry
    exit 1
    fi
    printf "$yell\tRECORDING TO :$cyan ${FILE_NAME}\n"
    sleep ${MINUTES}m
    kill ${PIDOF_CAT} && wait ${PIDOF_CAT} 2> /dev/null
    # pkill $ZAP_COMMAND # && wait ${PIDOF_AZAP} 2> /dev/null
    kill ${PIDOF_AZAP} && wait ${PIDOF_AZAP} 2> /dev/null
    printf "$yell\tFINISHED REC :$cyan ${FILE_NAME}\n$reset"
    remove_entry
    waiting 1
    function check_action {
    [ -e "$SCHED_FILE" ] || waiting $SLEEP
    [ "`cat $SCHED_FILE`" == "" ] && waiting $SLEEP
    DAY="0"; START="0"; FINISH="0"; CHAN="0"; NAME="0"
    TODAY=`date +%Y%m%d`
    NOW=`date +%k%M`
    while read -r DAY START FINISH CHAN NAME; do
    #printf "$DAY $START $FINISH $CHAN $NAME\n"
    break
    done < $SCHED_FILE
    if [ $DAY == $TODAY ] && [ $START -lt $NOW ]; then
    printf "$red\tOld Entry : Removing $CHAN $START\n"
    remove_entry
    waiting 1
    fi
    if [ $DAY == $TODAY ] && [ $START == $NOW ]; then
    record_entry
    else
    waiting $SLEEP
    fi
    function waiting {
    howlong=$1
    sleep $howlong && check_action
    check_action
    exit 0
    And the script that has been working fine 24hrs at a time
    #!/bin/bash
    echo alarm uses a twelve hour clock
    echo Type the time for the alarm to sound as 00-00-?m
    echo e.g. 05-35-pm for 5:35pm :: 05-35-am for 5:35am
    read TIME
    function play {
    A="$(date +%I-%M-%P)"
    if [ $A = $TIME ]; then
    for i in {1..10}; do
    $(aplay -c 1 /home/$USER/alarm/chime.wav); done
    exit
    else
    wait
    fi
    function wait {
    sleep 15 && play
    play
    I was hoping to have this script idling away in screen with rtorrent, always ready to do something if need be but that's not going to happen unless I can get a clue on what part of the script I need to change to not hit any limits. My websearches are failing me on this...
    Last edited by moetunes (2012-06-24 21:41:52)

    Thanks falconindy. I changed to using a while loop.
    #!/bin/bash
    set -o nounset
    shopt -s huponexit
    # User defines
    declare -i DVB_DEVICE_NUM="0"
    declare CHANNELS_CONF="${HOME}/Mychannels.conf"
    declare SAVE_FOLDER="${HOME}/TV/tele"
    declare SCHED_FILE="$HOME/.sched-tv"
    declare ZAP_COMMAND="tzap"
    declare -i SLEEP=15
    # Program defines
    declare -i DAY="0"
    declare -i START="0"
    declare -i FINISH="0"
    declare CHAN="0"
    declare NAME="0"
    declare -i MINUTES="0"
    declare -i REC_START="0"
    declare -i REC_HOURS="0"
    declare -i REC_MINS="0"
    declare -i howlong=$SLEEP
    declare -i PIDOF_AZAP=0
    declare -i PIDOF_CAT=0
    red='\033[1;31m'
    green='\033[1;32m'
    yell='\033[1;33m'
    cyan='\033[1;36m'
    white='\033[1;37m'
    reset='\033[0m'
    function remove_entry {
    if [ "$NAME" == "" ]; then
    sed "/$DAY $START $FINISH $CHAN/d" $SCHED_FILE > /tmp/dummy
    else
    sed "/$DAY $START $FINISH $CHAN $NAME/d" $SCHED_FILE > /tmp/dummy
    fi
    mv /tmp/dummy $SCHED_FILE
    function record_entry {
    ${ZAP_COMMAND} -a ${DVB_DEVICE_NUM} -f ${DVB_DEVICE_NUM} -d ${DVB_DEVICE_NUM} \
    -c $CHANNELS_CONF -r ${CHAN} >/dev/null 2>&1 &
    PIDOF_AZAP=$!
    if [ "$PIDOF_AZAP" == "" ]; then
    printf "$red\tError starting ${ZAP_COMMAND}.\n\tFAILED: $CHAN $START\n"
    remove_entry
    exit 1
    fi
    printf "$green\tSET CHANNEL$cyan ${CHAN}\n"
    REC_MINS=$((${START}%100))
    REC_HOURS=0
    MINUTES=0
    REC_START=$(($START-$REC_MINS))
    while [ $((${REC_START}+${REC_HOURS}+${REC_MINS})) -lt $FINISH ]; do
    ((REC_MINS++))
    ((MINUTES++))
    if [ ${REC_MINS} -ge 60 ]; then
    REC_MINS=0
    ((REC_HOURS+=100))
    fi
    done
    if [ "$NAME" == "" ]; then
    declare FILE_NAME="${SAVE_FOLDER}/TV-`date +%Y%m%d-%H%M`-ch.${CHAN}-${MINUTES}.min.mpg"
    else
    declare FILE_NAME="${SAVE_FOLDER}/TV-${NAME}-${MINUTES}.min.mpg"
    fi
    dd if=/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} \
    of=${FILE_NAME} conv=noerror &
    PIDOF_CAT=$!
    if (( ${PIDOF_CAT} == 0 )); then
    printf "$red\tError Starting Recording.\n\t/dev/dvb/adapter${DVB_DEVICE_NUM}/dvr${DVB_DEVICE_NUM} Unavailable\n"
    kill ${PIDOF_AZAP}
    remove_entry
    exit 1
    fi
    printf "$yell\tRECORDING TO :$cyan ${FILE_NAME}\n"
    sleep ${MINUTES}m
    kill ${PIDOF_CAT} && wait ${PIDOF_CAT} 2> /dev/null
    # pkill $ZAP_COMMAND # && wait ${PIDOF_AZAP} 2> /dev/null
    kill ${PIDOF_AZAP} && wait ${PIDOF_AZAP} 2> /dev/null
    printf "$yell\tFINISHED REC :$cyan ${FILE_NAME}\n$reset"
    remove_entry
    while true; do
    sleep $howlong
    howlong=$SLEEP
    [ -e "$SCHED_FILE" ] || continue
    [ "`cat $SCHED_FILE`" == "" ] && continue
    TODAY=`date +%Y%m%d`
    NOW=`date +%k%M`
    while read -r DAY START FINISH CHAN NAME; do
    #printf "$DAY $START $FINISH $CHAN $NAME\n"
    break
    done < $SCHED_FILE
    if [ $DAY == $TODAY ] && [ $START -lt $NOW ]; then
    printf "$red\tOld Entry : Removing $CHAN $START\n"
    remove_entry
    howlong=1
    continue
    fi
    if [ $DAY == $TODAY ] && [ $START == $NOW ]; then
    record_entry
    fi
    done
    exit 0
    I think that should be ok now.

  • [solved]Need help with a bash script for MOC conky artwork.

    I need some help with a bash script for displaying artwork from MOC.
    Music folders have a file called 'front.jpg' in them, so I need to pull the current directory from MOCP and then display the 'front.jpg' file in conky.
    mocp -Q %file
    gives me the current file playing, but I need the directory (perhaps some way to use only everything after the last  '/'?)
    A point in the right direction would be appreciated.
    thanks, d
    Last edited by dgz (2013-08-29 21:24:28)

    Xyne wrote:
    You should also quote the variables and output in double quotes to make the code robust, e.g.
    filename="$(mocp -Q %file)"
    dirname="${filename%/*}"
    cp "$dirname"/front.jpg ~/backup/art.jpg
    Without the quotes, whitespace will break the code. Even if you don't expect whitespace in any of the paths, it's still good coding practice to include the quotes imo.
    thanks for the tip.
    here it is, anyhow:
    #!/bin/bash
    filename=$(mocp -Q %file)
    dirname=${filename%/*}
    cp ${dirname}/front.jpg ~/backup/art.jpg
    then in conky:
    $alignr${execi 30 ~/bin/artc}${image ~/backup/art.jpg -s 100x100 -p -3,60}
    thanks for the help.
    Last edited by dgz (2013-08-29 21:26:32)

  • [SOLVED]bash script

    I had created a bash script which ensures that each of the applications has one instance. The problem is no applications are executed during startup. Here is my script:
    if [ -z "ps aux | grep wmCalClock | head -n -1" ]
    then
    wmCalClock -b 100 -arial -tc cyan -bc black -e xterm &
    fi
    if [ -z "ps aux | grep wmfire | head -n -1" ]
    then
    wmfire -L1 -B1 -s0 -C2 -P fireload_temp &
    fi
    if [ -z "ps aux | grep wmcpuload | head -n -1" ]
    then
    wmcpuload -lc red -a 95 &
    fi
    if [ -z "ps aux | grep wmmemload | head -n -1" ]
    then
    wmmemload -lc red -am 95 &
    fi
    Last edited by heyya (2009-12-25 04:19:33)

    Well, obviously not, as the string "ps aux | grep wmCalClock | head -n -1" is
    never empty What you probably wanted to write is
    "$(ps aux | grep wmCalClock | head -n -1)"
    This will put the output of the script into the string, rather than taking the
    command string itselft.

  • [SOLVED] How to get BASH scripts to recognize mounted partition paths?

    I don't understand how to get the bash script in the root partition to find the boot partition--both mounted at /mnt.
    I'm following the instructions on configuring "dm-crypt with LUKS" tutorial. The mkinitcpio command to generate the "initial ram disk environment" is producing an error while the system is booted from the install disk and the volumes it looks for are mounted at /mnt.
    #mkinitcpio -p linux
    ==> Building image from preset: /etc/mkinitcpio.d/linux/preset: 'default'
    -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
    ==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux'
    ==> Building image from preset: /etc/mkinitcpio.d/linux/preset: 'fallback'
    -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
    ==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux`
    The script located in /mnt/root/etc can't find the "temporary kernel" located at /mnt/boot.
    Last edited by xtian (2013-09-17 22:01:35)

    And read them carefully, there should be no /mnt/root/etc/.
    There should be a /mnt/etc/ and a /mnt/boot and /mnt/root/ which is the root user's home directory, not the root filesystem (and of course /mnt/usr ...) - or if you decide to nest the whole thing deeper you could have /mnt/somename/etc and /mnt/somename/boot ...

  • [SOLVED] XMMS2 media hotkeys, bash scripts

    Hi!
    For the really beginners of the XMMS2 users as me, should be a nice something like a guide/tutorial.
    Here is the bash scripts that might enchant functionality and be more useful for use of the media keys.
    For randomizing before any other action you can use even something like:
    xmms2 playlist shuffle ; xmms2 jump 1; xmms2 play
    # Just for dummies
    The Preview hotkey loop.
    From the begin of the playlist to the end of it when current is the first one being played:
    #!/bin/bash
    #Play the previews or first if end of the playlist
    if [ "XX"$(xmms2 prev | awk '{print $1}') == "XXServer" ] ; then
    if [ "XX"$(xmms2 jump $(xmms2 list | grep -i '/' |wc -l) | awk '{print $1}') == "XXServer" ] ; then
    xmms2 playlist list;
    echo The playlist is empty, please choose one from of the above ;
    echo or add a new songs to the playlist with a '"xmms2 add"';
    fi; fi;
    #It takes time to count to the last song in the playlist, longer it is more time it takes :(. I haven't found a better way yet.
    The Next hotkey loop.
    When the end of the playlist is reached then goto jumping to the first one song in the playlist:
    #!/bin/bash
    #Play the first song if in the end of the playlist
    if [ "XX"$(xmms2 next | awk '{print $1}') == "XXServer" ] ; then
    if [ "XX"$(xmms2 jump 1 | awk '{print $1}') == "XXServer" ] ; then
    xmms2 playlist list;
    echo The playlist is empty, please choose one from of the above ;
    echo or add a new songs to the playlist with a '"xmms2 add"';
    fi; fi;
    For the Play/Pause key:
    #!/bin/bash
    #For the single Play/Pause key
    GetStatus=$(xmms2 current | awk -F":" '{print $1}')
    #Any command line parameters to the script for randomizing of the playslist.
    if [ "S" != "S"$1 ] ; then
    xmms2 playlist shuffle
    fi;
    if [ "$GetStatus" == "Playing" ]; then xmms2 pause;fi
    if [ "$GetStatus" == "Paused" ]; then xmms2 play;fi
    if [ "$GetStatus" == "Stopped" ]; then
    xmms2 play
    GetStatus=$(xmms2 current | awk -F":" '{print $1}')
    if [ "$GetStatus" == "Stopped" ]; then
    xmms2 playlist list;
    echo The playlist is empty, please choose one from of the above ;
    echo or add a new songs to the playlist with a '"xmms2 add"';
    fi
    fi
    or you can use even xmms2 toggle command line for the play/pause hotkey.
    Turn On/Off repeat/loop of the playlist:
    #!/bin/bash
    GetStatus=$(xmms2 server config playlist.repeat_all )
    case $GetStatus in
    "playlist.repeat_all = 1") xmms2 server config playlist.repeat_all 0 ; sudo beep; echo is OFF ;;
    "playlist.repeat_all = 0") xmms2 server config playlist.repeat_all 1 ; sudo beep ; sudo beep ; echo is ON;;
    esac
    You can install beep but the beep has a problem, you can run it only as a root but a more danger way is to by pass this by adding the beep into /etc/sudoers , e.g. yourusername ALL=NOPASSWD: /usr/sbin/beep.  Be careful! It may expose your system for unwanted access to and do a harm. The best way is to find a better way for notification of changes.
    If someone has another script solutions for the multimedia hotkeys or media fun for XMMS2 then please share with us!
    Automation is power of the shell
    Notice
    The hotkey names of my Digital Media Keyboard 3000, but I think that it becomes more as a standard, it is just to get a faster access to the names.
    XF86AudioPlay, XF86AudioNext, XF86AudioPrev,XF86AudioStop
    XF86AudioMute (amixer -c 0 set Master toggle), *, (pactl set-sink-mute 0 toggle)
    XF86AudioRaiseVolume (amixer -c 0 set Master 3+), xmms2 server volume +3, (pactl set-sink-volume 0 +3%)
    XF86AudioLowerVolume (amixer -c 0 set Master 3-). xmms2 server volume -3, (pactl set-sink-volume 0 -- -3%)
    amixer = ALSA
    pactl = PulseAudio (0 is index of the sinks, you can see which you can use with pacmd list-sinks, marked with * is default)
    The other way to increase and decrease volumes is here.
    Change between ALSA and PulseAudio sound servers for XMMS2
    nyxmms2 server config output.plugin pulse
    nyxmms2 server config output.plugin alsa
    Otherwise you can use xev to retrieve the names of the supported keys by X server, as I know X server has a limitations to the 255 key numbers/keycodes. One more but less useful for GUI is showkey, just to know that it is also and always exists, with a great manual about the kbd keys.
    * To mute/unmute XMMS2 you can use xmms2 server volume 0 / xmms2 server volume 100 or for more advanced e.g. xmms2 server volume -c left 100/xmms2 server volume -c right 100 and combine with any keys you wish the way is best for you. I haven't found any way to make anything to remember status after mute/unmute of xmms2. Alias for the mute only is xmms2 mute. If you will find it before me please help .
    Here is one more guide for the BlackBox menu. I could not get xmms2 mlib loadall to work in Arch.
    In Arch you must use xmms2 playlist sort instead of xmms2 sort because it doesn't work otherwise.
    xmms2 playlist sort album
    xmms2 playlist sort title
    xmms2 playlist sort artis
    Last edited by Andy_Crowd (2014-10-18 11:34:45)

    Zariel wrote:
    i guess something like this?
    %optical ALL=(ALL) NOPASSWD: ALL
    I found the clues for this in the sudoers manual:
    handy   ALL = NOPASSWD: /sbin/umount /CDROM,\
                    /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
    Which works in so far as now mounting no longer needs the password.
    Which leaves me with the problem of trying to understand how to get Worker to mount the optical drive on command.
    If I enter the bash command in the Terminal as follows:
    mount /mnt/dvd
    the media is mounted, after which I can push the button in Worker, which I have configured with:
    /mnt/dvd
    & the root list of the optical media is displayed in the active panel of Worker.
    I just haven't been able to get Worker to use "mount /mnt/dvd" yet, there will be a way, I wonder how long it will take me to find it? lol
    Last edited by handy (2008-11-19 06:48:09)

  • [SOLVED] Bash scripts to mount & unmount optical drive in Worker?

    I'm running XFCE on Arch with the HAL daemon being called in /etc/rc.conf.
    I can access media on my optical drive (DVD's or CD's) through the desktop icon that appears after HAL has recognised the drive, VLC automatically does its thing as does NeroLinux.
    The reason I'm posting is that I found a great DOpus clone yesterday called Worker - http://www.boomerangsworld.de/cms/worker/index?lang=en, which I am in the process of configuring.
    A problem I have is being able to access the optical drive via Worker.
    The way it is on my system, with HAL handling it, the first line (see below) appears after HAL mounts the media, which basically makes the two lines below it useless:
    /media/<title of disk>
    /media/cd
    /media/dvd
    I have tried configuring Worker to use /media/dvd (or cd), to access the optical media, these don't work for the reason stated above, & /dev/sd0 doesn't work either.
    So, do I have to turn off HAL, uncomment the lines in fstab & use mount?
    A little bash script, that would do the job for me would be great, as Worker will accept a script or a command string.
    I am a bash baby, so if someone can see a solution please post it?
    All input welcome.
    Thanks.
    Last edited by handy (2008-11-19 04:11:02)

    Zariel wrote:
    i guess something like this?
    %optical ALL=(ALL) NOPASSWD: ALL
    I found the clues for this in the sudoers manual:
    handy   ALL = NOPASSWD: /sbin/umount /CDROM,\
                    /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
    Which works in so far as now mounting no longer needs the password.
    Which leaves me with the problem of trying to understand how to get Worker to mount the optical drive on command.
    If I enter the bash command in the Terminal as follows:
    mount /mnt/dvd
    the media is mounted, after which I can push the button in Worker, which I have configured with:
    /mnt/dvd
    & the root list of the optical media is displayed in the active panel of Worker.
    I just haven't been able to get Worker to use "mount /mnt/dvd" yet, there will be a way, I wonder how long it will take me to find it? lol
    Last edited by handy (2008-11-19 06:48:09)

  • [Solved] Selecting folder span in bash script

    Hey all,
    Recently, I decided to get an audio-book from Audible and discovered the mp3 player they advertise about is only for ipods.  This meant that the only legit way to transfer it to my mp3 player (an .aa file/DRM protected) was to use iTunes burn it to multiple cds.  Doingthis had the book span 14 disks and now I'm trying to put it back together.  I used a great program called 'ripit' to rip the files back to Linux and now I'm faced with the task of concatenating the files back together again.  Ripit ripped the disks to 14 separate folders:
    Unknown Artist - Unknown Album
    Unknown Artist - Unknown Album 1
    Unknown Artist - Unknown Album 2
    Unknown Artist - Unknown Album 13
    To get these to appear in correct order I first rename the first album:
    mv Unknown\ Artist\ -\ Unknown\ Album/ Unknown\ Artist\ -\ Unknown\ Album\ 0
    replaced white spaces with hyphens (necessary for the next step):
    find -name "* *" -type d | rename 's/ /-/g'
    Zeropad the numbers to show in the right order (using this persons excellent script - http://www.walkingrandomly.com/?p=2850):
    for i in *; do mv "$i" $(zeropad "$i"); done
    #!/bin/bash
    # zeropad
    # Filter that will take input with basic numbering and zero pad it (i.e. file002)
    # e.g. mv file1.png `$(zeropad) $i`
    # http://www.walkingrandomly.com/?p=2850
    num=`expr match "$1" '[^0-9]*\([0-9]\+\).*'`
    paddednum=`printf "%03d" $num`
    echo ${1/$num/$paddednum}
    So now my directories look like this:
    Unknown-Artist---Unknown-Album-000
    Unknown-Artist---Unknown-Album-001
    Unknown-Artist---Unknown-Album-013
    Now I'm trying to create a bash script that will put this mp3s back together again.  mp3cat is the right utility to do this so I need to create a bash script that I can tell what folders to use to put them together.  Originally the book from Audible came in three parts:
    SK...part1.aa
    SK...part2.aa
    SK...part3.aa
    part 1 covers directories 000 to 004, part 2 005 to 008, part 3 009 to 013.  The script though I'd like to be generic (to be able to accept input if I decided to ever do this again).  Here it is thus as I have it so far figured out:
    echo "Join multiple mp3s from which folders?"
    echo -n "First folder number [0xx]: "
    read first_folder
    echo -n " to folder number [0xx]: "
    read final_folder
    echo -n " Name of file [name].mp3: "
    read filename
    for f in Unknown-Artist---Unknown-Album-[$first_folder-$final_folder]; do
    cat "$f"/*.mp3 | mp3cat - - > "$filename".mp3
    done
    I'd like to be able to input which directory to begin with and then input which directory to end with.  My use of [$first_folder-$final_folder] here shows my limited use of bash and I know that this this is only going to work for a single digit.  Any ideas what I can do here?
    Last edited by Gen2ly (2011-09-19 02:25:04)

    If there are spaces in the filenames then using globbing won't change anything. When stored in an array the new elements are split at spaces. This has the same problem as using ls. edit: ok so, "newer" versions of bash won't split the elements at spaces but the spaces still screw up when the array is expanded to command arguments.
    As usual all problems of existence are just a primitive form of bending. I mean, sorting! Crap. No need to remove the spaces and rename everything. sort and awk like spaces.
    # Must... have... number!
    mv "Unknown Artist - Unknown Album" "Unknown Artist - Unknown Album 0" \
    2>/dev/null
    # Sort & awk read as many number chars as possible, then give up.
    # ./Unknown Artist - Unknown Album 1/Track 1.mp3
    # (Fields) 6_/*^^^^^^ *^^^^\_7
    find . -name '*.mp3' | sort -n -k6 -k7 | \
    # $6+0 coerces $6 into a number.
    awk -v beg="$1" -v end="$2" '$6+0 >= beg && $6+0 <= end' |
    # Use NULL chars instead of newlines to make xargs happy.
    tr '\n' '\0' | xargs -0 cat
    # Without NULL chars and -0, xargs splits on lines AND spaces. Bad.
    Instead of changing the data (paths) to make it sort lexicographically, I simply sorted the data explicitly. Two args: beginning number and ending number. It's probably too late, since you renamed everything but maybe you can use the tr | xargs trick. Avoid using bash arrays or get rid of the spaces in the filenames.
    Last edited by juster (2011-09-18 13:02:59)

  • Forms 10g compile : syntax error near unexpected token `in

    Hi,
    I am writing a code to compile FORMS 10g(10.1.2.0.2) in HP_UX one by one.
    this is the code---frm10g.sh
    *#!/bin/ksh*
    *# . ~oracle/forms/server/default.env*
    *# . sid icache*
    TERM=vt220
    *if [ $# != 2 ]*
    then
    echo Usage : $0 module_name module_type
    exit 1
    fi
    case $2 in
    FORM|form|F|f) ext1='fmb' ;ext='fmx' ; modtyp='FORM' ;;
    PLL|pll|p|lib|LIB) ext1='pll' ;ext='plx' ; modtyp='LIBRARY' ;;
    MENU|menu|M|m) ext1='mmb' ;ext='mmx' ; modtyp='MENU' ;;
    **) echo invalid parameter ; exit 1 ;*
    esac
    echo Generating $1.$ext
    frmcmp module=$1.$ext1 userid=abc/abc@abc output_file=../$1.$ext module_type=$modtyp batch=NO compile_all=special > ./log/$1.log
    when I try to excute above file frm10g.sh in command line i get following error. Please let me know how to fix it.
    [abc]u01/app/oracle/product/10.1.2/forms/forms/Forms10g:. frm10g.sh INV FORM
    : command not found
    : command not found
    'bash: ./frm10g.sh: line 13: syntax error near unexpected token `in
    'bash: ./frm10g.sh: line 13: `case $2 in
    I really aapreciate your help.
    Thanks
    Sandy

    Sandy,
    I must apologize. The Compile.sh does not come with the Oracle Dev Suite installation. However, the following is the contents of the compile.sh script we use. This script compiles a single form.
    #!/usr/bin/ksh
    ORACLE_HOME=/d01/oracle/ias1012;export ORACLE_HOME
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$ORACLE_HOME/ctx/lib:/usr/java1.2/jre/lib/sparc:$ORACLE_HOME/jdk/jre/lib/sparc:/usr/lib:/usr/dt/lib:/usr/openwin/lib:/usr/ucblib:usr/ccs/lib; export LD_LIBRARY_PATH
    MODULE_NAME=`echo $1|cut -d. -f1`
    MODULE_SUFFIX=`echo $1|cut -d. -f2`
    MODULE_MESG=${2:-"Compiling $1"}
    OK_MESG=${3:-"  Compiled sucessfully"}
    . .setpass_cir
    APP_PW='cir/'`eimauth -g cir`'@database'
    echo "************************************************************************* "
    echo ${MODULE_MESG}
    frmcmp.sh module=/d01/oracle/forms/${MODULE_NAME}.fmb userid=${APP_PW} compile_all=yes batch=yes
    RC=$?
    case "$RC" in
      0)
        echo ${OK_MESG}
        echo "Compile errors, return code: $RC "
        cat ${MODULE_NAME}.err
        echo "Compile errors in $1, press [enter] to continue.\c"
        read x
    esac
    eval exit $RCYou should be able to modify this to suit your needs.
    Craig...

  • PowerShell command returned an exception. Unexpected token 's' in expression or statement

    Hi All,
    I am trying to Creating a VM based on a Template in VMM through Orchestrator Runbook using below URL;
    http://blogs.catapultsystems.com/lrayl/archive/2013/07/03/orchestrator-system-center-integrations-part-3-creating-a-vm-based-on-a-template-in-vmm.aspx
    Runbook:
    But at the Create VM from Template activity runbook will failed:
    Throwing below error in while running runbook in Error Summary text:
    PowerShell command returned an exception. Unexpected token 's' in expression or statement.
    Exception: InvalidOperationException
    Target site: PSRunspaceInvoker.HandleInvokeException
    Stack trace:
       at Microsoft.SystemCenter.Orchestrator.Integration.PowerShellConnector.PSRunspaceInvoker.HandleInvokeException(Exception ex, ILogger logger)
       at Microsoft.SystemCenter.Orchestrator.Integration.PowerShellConnector.PSRunspaceInvoker.Invoke(RunspaceInvoke runspace, String script, ILogger logger)
       at Microsoft.SystemCenter.Orchestrator.Integration.PowerShellConnector.PSScriptRunner.Execute(String script)
       at Microsoft.SystemCenter.Orchestrator.Integration.VMM2012Domain.VM.CloneFromTemplate(String vmmServer, ParameterList inputParameters)
       at Microsoft.SystemCenter.Orchestrator.Integration.VMM2012QIK.VM.CloneFromTemplate.DoExecute(IActivityRequest request, ILogger logger)
       at Microsoft.SystemCenter.Orchestrator.Integration.VMM2012QIK.ActivityBase`2.Execute(IActivityRequest request, IActivityResponse response)
    Both Orchestrator & SCVMM powershell are set on Unrestricted powershell.
    Kindly suggest any solution or work around for resolution.
    Thanks Rahul$

    This may be a bit late and perhaps not even relevant but I came across this post when trying to solve an issue I had with a powershell script in Orchestrator. Maybe it will help you, or maybe it will help someone else.
    I was trying to create a connector between SCOM and our ticketing system. I wanted to export alert descriptions and in the process of testing I came across an alert description that had multiple lines and all kinds of crazy formatting. When I tried to assign
    the Published Data to a varialbe in my powershell script i would get an error "Unexpected token [a partial alert description] in expression or statement.". After looking at the actual alert description data and seeing that i was only getting some of it
    and not all of it it dawned on me that i somehow needed to escape out of all the crazy quoting, carriage returns, and special characters. to do that i assigned the Published Data to a variable in my powershell script as follows:
    $Description = @"
    {Description from "Get Alert"}
    Apparently the @" "@ is called a here-string. Somewhat interesting. Hope it helps you or someone else!

  • Unexpected token: {

    Trying to check how LV 2011/Mathscript supports clusters, I tried a Matlab script written by a colleague (function definition) and could not get it to pass the parsing stage in the Mathscript node.
    After correcting a few things that are not supported yet (such as the use a "~" for a dummy variable name, or anonymous function declaration), I ended up with a bizarre message:
     unexpected token: {
    The details show:
    Line 346, Column 4: unexpected token: {
    Line 346, column 4 is the end of the script, following a "end" declaration, which ends a sub-function declaration. There is no "{" character there.
    What gives?
    Solved!
    Go to Solution.

    Hi X.,
    There are a couple more issues in your script:
    1. When using multiple functions within a single m-file we currently don't support the use of "end" at the end of a function description. For example, this would be ok:
    function a = foo(x) 
     a=x;
    function b = bar(y) 
     if y>3 
      b=y;  
    wheras this would error:
    function a = foo(x) 
     a=x;
    end
    function b = bar(y) 
     if y>3 
      b=y; 
     end
    end
    2. If possible you may wish to refrain from using global variables since it causes the MathScript Node to run in decreased performance mode. For more info look here.
    3. You are still using varargin (which is not supported) in the Likelihood_subfunction parameters. You should treat this like you treated the original function call by replacing it with the total number of inputs you wish to use. In this case the four inputs required for the subfunction call.
    4. You are using optimset to pass options to fminsearch. Currently optimset is not supported. Our default values for max iterations and max function calls are 100 and 1000 respectively. If you really need to set these values to something different we may have some ideas. Please send me a pm if that is the case. 
    5. Finally, the syntax you use for fminsearch is not correct in MathScript. Our current implementation of fminsearch only supports two outputs. Having a third output (errflag) will cause this function to give an error.
    This script has been very useful to use in providing a usecase for support that we currently lack. Thanks for sharing and let us know if we can be of more help.
    Thanks,
    K Scott

Maybe you are looking for

  • How to know side effects of implementing an SAP Note

    Hi All, Im new in implementing SAP Note. Kindly suggest how to analyize whether implementing an SAP Note will cause some side effect. How to do that ,I think just by looking at code can we assure that there will be no side effects. Kindly suggest.

  • HT204406 Can't download music (err = 11111) and (err = -50)

    I recently reformatted my computer due to a problem with the hard drive. Luckily all my music was in the cloud. However, now I cannot download MANY of my songs (about 15-20) due to *stopped (err = 11111)* and *stopped (err = -50)*. I paid for this mu

  • No images, not able to edit TOC

    I cannot seem to change anything in the toc. no images are uploaded, no matter what i do in inspector nothing changes. not cohesive. help please!

  • Character string of en_AE and en_IL supported by CS6 is not reflected in a dialog title of plugin.

    Character string of en_AE and en_IL supported by CS6 is not reflected in a dialog title of plugin. [Development environment] Flex SDK 3.4 Extension Builder 2.0 Flash Builder 4.6 Does development environment have restrictions?

  • Transport jump ahead during streaming

    I am using Quicktime pro and cannot get the transport to jump ahead in a streaming movie.  I cannot drag it or manually enter a time to go to.  It works in a movie residing on my hard drive, but not streaming.  Is Quicktime capable of this or is it a