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.

I've spent a lot more time than I was expecting and was hoping I could get some help debugging.

My goal is to sync files between my documents and my usb drive as soon as it is mounted.

I've consulted a lot of posts on this, but these two have been the most beneficial.

Autorun a script after I plugged or unplugged a USB device

How to run a script when a specific flash-drive is mounted?

My scripts work. I have executed them by hand, and they create log files which tell me they are running and performing the files I tell them to.

What I don't know if the rules from udev are executing the RUN command. Here's all the stuff.

typing usb reveals the following of the device of interest:

Bus 003 Device 015: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102 Flash Drive / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick

File: /etc/udev/rules.d/00-usb-kingston.rules

ATTRS{idVendor}=="0930", ATTRS{idProduct}=="6545"
ACTION=="add", RUN+="sh /home/holiestcow/.bin/usb-kingston-in_dev"

Typing udevadm rules /etc gives me the following:

parse_file: reading '/etc/udev/rules.d/00-usb-kingston.rules' as rules file

File: /home/holiestcow/.bin/usb-kingston-in_udev

#!/bin/bash
echo "in_udev" > progress.txt
/home/holiestcow/.bin/usb-kingston-in &

File: /home/holiestcow/.bin/usb

#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/holiestcow/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME

echo "kingston-in part dos" >> progress.txt
rsync -auv --delete -n /media/CARLO\ GEN/ /home/holiestcow/Documents/ >> progress.txt
rsync -auv --delete -n /home/holiestcow/Documents/ /media/CARLO\ GEN/ >> progress.txt

Future thanks for your help.

share|improve this question
add comment

1 Answer

How to easily add scripted actions on various events

I know this is missing the "using udev"-part of your question, but you might still be interested.

Install cuttlefish Install banshee

I use it myself for automated-script when I connect to different WLan APs. It's dead-easy to setup. OMG-Ubuntu has an article on it.

share|improve this answer
    
Thank you so much. I'm pretty fed up with the udev route. I think this will do quite nicely. –  user215920 Nov 17 '13 at 20:21
    
Can I beg you to accept my answer and to gratify my effort? Thanks :) –  MadMike Nov 22 '13 at 12:53
add comment

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.