Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If this is not the best place to post this question, can you please direct me to a more appropriate place to post this.

What I am trying to do:

I have a USB drive, it is fat32 and its name is JavaClasses. Whenever I plug it in it is mounted and its accessable path is /media/bill/JavaClasses. I have a script that when I run it, it checks to see if the JavaClasses directory exists, if it does, it will make a directory with this format, yyyymmddhhmm. Then the script will copy (backup) my eclipse directory to this new directory. I have created a new rule under /etc/udev/rules.d/85-javaclasses.rules. This will launch the above script. The script has a 2 second delay to allow the mounting.

current situation:

the script runs fine if I run in manualy. It does not run automaticly when the drive is pluged in.

the command line and info:

this is the command in the 85-javaclasses.rules.

SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0930", ATTRS{idProduct}=="6545", RUN+="/home/bill/bin/javaclasses.sh"

This is what I get when I run

udevadm info --attribute-walk --name /dev/sdb1


looking at parent device '/devices/pci0000:00/0000:00:07.0/0000:04:00.0/usb10/10-1/10-1.4':
    KERNELS=="10-1.4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="1.4"
    ATTRS{idVendor}=="0930"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="10"
    ATTRS{devnum}=="4"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="200mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0100"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="001A4D5E4020ED5199130595"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="2197"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Kingston"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="6545"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="DataTraveler 2.0"

Can anyone point me in a direction to have this resolved.
Thank you for your time.

share|improve this question

1 Answer 1

Just try a simple command loop, very low processing power, but useful.

#!/bin/bash
x=0
while [ true ]
    do if [ $x = 0 ]
        then if [ -s /media/myflashdrive/* ]
            then bash /home/user/myscript.sh
            x=1
        fi
        else if [ -s /media/myflashdrive/* ]
            then true
            else x=0
        fi
     fi
sleep 10
done

Save this in /etc/ and add this line to /etc/rc.local :

bash /etc/this_script.sh &

Make sure you add that before the exit 0. Done! Whenever your flashdrive mounts myscript.sh will run, then when its unmounted, x will equal 0 again and the script will start looking for it again for you to plug it in!

share|improve this answer
    
This will run a non stop loop looking for the media every 10 seconds. Once it backs up the program stops. The problem here is if I want to back up 2-3 times a day with out restarting. I am looking for a soution that could use udev. –  EglCode Aug 7 '13 at 20:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.