Page 5 of 5 FirstFirst ... 345
Results 41 to 43 of 43

Thread: howto run a script when a USB device is pluged in

  1. #41
    Join Date
    Sep 2011
    Beans
    2

    Re: howto run a script when a USB device is pluged in

    Hello Everyone
    I have big problem with a simply script. I need automatic copy all files from USB pendrive to my folder in HDD, every time when I will plug USB device.
    I used rule :

    ACTION=="add", KERNEL=="sd?", SUBSYSTEM=="usb", RUN+="/home/art/bin/copy.sh"

    and (first) script copy.sh

    #!/bin/sh
    mountdir="/media/`blkid /dev/sd? | awk {'print $2'} | sed -e 's/LABEL=//' -e 's/"//g'`"
    dstdir="/home/art/Wideo/"
    mkdir -p $dstdir
    cp -r $mountdir $dstdir
    chmod -R 777 $dstdir

    (second)

    #!/bin/sh
    find /media/ -name "*[mpg|avi|mov|mp4]" -exec cp {} /home/art/Wideo \; chmod -R 777 /home/art/Wideo

    Unfortunetly both of scripts works when I run them from file, but not working when i plug my USB device.
    I have Ubuntu 11.04
    Any suggestions?
    Last edited by jarazz; September 11th, 2011 at 02:57 PM.

  2. #42
    Join Date
    Apr 2010
    Location
    Belgium
    Beans
    14
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: howto run a script when a USB device is pluged in

    what kind of USB device?

  3. #43
    Join Date
    Sep 2011
    Beans
    2

    Re: howto run a script when a USB device is pluged in

    Quote Originally Posted by tumutanzi View Post
    what kind of USB device?
    Pendrive

Page 5 of 5 FirstFirst ... 345

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •