0

I'm been trying to get a rule to trigger when plugging in my camera(eos r) to further automate photo importing and the like, but I cant get the initial rule to trigger. I'm new to linux in general & am using Ubuntu 20.04.1 LTS.

lsusb yields this information Bus 002 Device 003: ID 04a9:32da Canon, Inc. Canon Digital Camera

The rule /etc/udev/rules.d/91-camerabackup.rules

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="32da", RUN+="/home/thele/photo_backup.sh"

I've tried using chmod chmod 0644 /etc/udev/rules.d/91-camerabackup.rules

I've tried various times to reboot or use udevadm control --reload-rules && udevadm trigger

The bash script resides in /home/thele/photo_backup.sh. Just executing bash /home/thele/photo_backup.sh creates a folder.

echo "Do Folder Camera Stuff"
mkdir camshelltest

I assume that this is enough to test out whether the rule works. What else I am missing? Or is there any other way to approach this?

5
  • Does /home/thele/photo_backup.sh have an appropriate shebang, and is it executable (i.e. can you run /home/thele/photo_backup.sh without the explicit bash command)? Dec 19, 2020 at 22:33
  • ok just briefly learned of this, added #!/bin/bash to the top of the script and used chmod +x photo_backup.sh on it. /home/thele/photo_backup.sh runs without the explicit bash command, and creates a folder but the rule itself still does trigger when plugging the camera in again.
    – thelebaron
    Dec 20, 2020 at 1:39
  • Where did you check for the folder? remember that mkdir camshelltest will create a directory wherever the working directory of the rule is (likely the filesystem root, /). Likewise, remember that echo "Do Folder Camera Stuff" won't have a terminal to echo the string to. Dec 20, 2020 at 1:47
  • Use mkdir $HOME/camshelltest.
    – waltinator
    Dec 20, 2020 at 4:46
  • thanks guys! not sure how to mark this as answered but the folder was being made in the root instead of where I was expecting it to be. I am also assuming making it executable helped things, and finally fixed my script to be an absolute path rather than a relative one.
    – thelebaron
    Dec 20, 2020 at 19:09

0

You must log in to answer this question.

Browse other questions tagged .