Answer the question
In order to leave comments, you need to log in
How to copy a file from USB drive linux?
Hello. There is a task to automatically copy a file from a USB flash drive when it is inserted into a usb port.
But I have a problem.
I created a rule in udev rules when inserting a flash drive with a specific vid & pid to run the script ( goo.gl/yYQeq5 )
sh is in the user's folder, creates a folder, mounts the flash drive into it (sudo mount) looks for the file and copies it from the flash drive, let's say to hom, then unmount the flash drive. All.
The script works if you insert a flash drive and run it manually, but it does not work with /etc/udev/rules.d
The rule was created correctly.
I added the script to the root group and set the permissions to 4655. The
question is how to run this script as root in udev rules?
Maybe there is some other option. Please advise.
Thank you.
Answer the question
In order to leave comments, you need to log in
Stick in the script
And insert the flash drive.
Two things will be visible at once:
- whether the script is really launched by udev
- on whose behalf it is launched
I remember that udev always executes scripts as root. Did you forget to restart udev, by the way?
Genius
opened the file, didn't see that it didn't add # to #!/bin/bash
file showed that
Yudev restarted as root
Thank you!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question