SOLVED: How can I write a script to do the following ...

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
User avatar
Pepi
Level 5
Level 5
Posts: 721
Joined: Wed Nov 18, 2009 7:47 pm

SOLVED: How can I write a script to do the following ...

Post by Pepi » Wed Dec 06, 2017 11:29 am

I have a USB device that will create a hidraw file in /dev when it is attached. after you unplug the device the file is deleted :cry: How can I write a script that I can run after plugging in the device. The hidraw file needs the permissions changed for some reason? I've been doing the below on the command program but I would like to be able to just run a script to do this.
Thanks


cd ../..

cd dev

sudo chmod 777 hidraw*
Last edited by Pepi on Thu Dec 07, 2017 8:33 am, edited 1 time in total.

rene
Level 8
Level 8
Posts: 2226
Joined: Sun Mar 27, 2016 6:58 pm

Re: How can I write a script to do the following ...

Post by rene » Wed Dec 06, 2017 11:46 am

You shouldn't write a script as such but a udev rule. Which, mind you, only come across as intimidating. Usually and in this case someone else has already done the work and you only need to place a single-line file somewhere under /etc/udev/rules.d. See first (self-)answer at https://unix.stackexchange.com/question ... ermissions

User avatar
Pepi
Level 5
Level 5
Posts: 721
Joined: Wed Nov 18, 2009 7:47 pm

Re: How can I write a script to do the following ...

Post by Pepi » Wed Dec 06, 2017 12:17 pm

Thank you kind sir :D Worked like a charm.

I added KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev" to a file and that's IT :mrgreen:

Post Reply

Return to “Newbie Questions”