Udev rule running a scriptUdev not running scriptsUdev rule to create node for character device when loading moduleudev script doesn't run in the backgroundWhy my udev rule not workingudev rule upon connecting any USB device (Ubuntu 16.04)udev rule to run Python scriptWhy is my udev rule not working?Custom notification from udev ruleudev forgets about tag in custom rule

Find all matrices satisfy

How fast are we moving relative to the CMB?

Anonymous reviewer disclosed his identity. Should I thank him by name?

Does the DOJ's declining to investigate the Trump-Zelensky call ruin the basis for impeachment?

Should I be able to see patterns in a HS256 encoded JWT?

The answer is the same (tricky puzzle!)

As an interviewer, how to conduct interviews with candidates you already know will be rejected?

How can I find places to store/land a private airplane?

Did S. Lang prove Kuratowski–Zorn lemma without Axiom of choice or Well-ordering theorem?

SHA3-255, one bit less

What benefits are there to blocking most search engines?

Redirect output on-the-fly - looks not possible in Linux, why?

Why is my vegetable stock bitter, but the chicken stock not?

How do I know how many sub-shells deep I am?

Is there a pattern for handling conflicting function parameters?

Did the Soviet army intentionally send troops (e.g. penal battalions) running over minefields?

Parent asking for money after I moved out

Can I return my ability to cast Wish by using Glyph of warding?

Generating Roman numerals with dice

Is it unethical to give a gift to my professor who might potentially write me a LOR?

Was Smaug sealed inside the Lonely Mountain?

Quote to show students don't have to fear making mistakes

Driving test in New Zealand?

"last" command not working properly



Udev rule running a script


Udev not running scriptsUdev rule to create node for character device when loading moduleudev script doesn't run in the backgroundWhy my udev rule not workingudev rule upon connecting any USB device (Ubuntu 16.04)udev rule to run Python scriptWhy is my udev rule not working?Custom notification from udev ruleudev forgets about tag in custom rule






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0















I've spent some time running through threads on this and I do not think any syntax is off, please tell me why is this not executing the script.



udev rule:



ACTION=="add", KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSserial=="C*", RUN+="/usr/bin/log-cp-usb.sh", OPTIONS="last_rule"


script log-cp-usb.sh:



rsync -av /home/pi/Downloads /media/pi/41AA-EDC6


I've tried several variations of the rule (latest addition is the OPTIONS tag) and the script runs successfully by calling it directly.Thoughts?



Update: I apologize, my script does have the #!/bin/bash at the top (I omitted because I thought it would be assumed). I've also tried #!/bin/sh and the script is in the located path destination folder, and is executable. I can go into the folder and execute the script using ./log-cp-usb.sh, using this command outside the folder returns no file present so the path should be sufficient for the rule command. @dessert I tried the latter advice to no avail It will just not run on usb insert.



Update: I've gone back to the basics and simplified the code. I'm still using a bash script that is pointed at by the udev rule.



rule:



KERNEL=="sdb1", SUBSYSTEM=="block", RUN+="/usr/bin/autocopy"



script along path /usr/bin/autocopy:



#!/bin/bash
cp -a /home/pi/Downloads/. /media/pi/41AA-EDC6/



Entering the /usr/bin directory and executing ./autocopy successfully copies the contents of the downloads folder to the designated path which is where the usb is mounted. The issue still remains that even with the created rule, the script does not run when the usb is first inserted. Advice?



Update: All scripts were made executable using chmod +x while in the file directory they were created, i.e. while in /usr/bin I executed chmod +x *script name* for both log-cp-usb.sh and autocopy. Both are independently executable using ./ command but the udev rule will not RUN+= them



Update: sudo visudo was also updated by adding pi ALL=(ALL) NOPASSWD: /usr/bin/*script name* for both autocopy and log-cp-usb.sh










share|improve this question


























  • Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

    – Sergiy Kolodyazhnyy
    Apr 16 at 15:39






  • 1





    Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

    – danzel
    Apr 16 at 16:46











  • @danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

    – Austin Michalik
    Apr 16 at 17:11












  • Unfortunately, after the change the program is still not running on usb insertion

    – Austin Michalik
    Apr 16 at 17:13











  • Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

    – WinEunuuchs2Unix
    Apr 16 at 19:41

















0















I've spent some time running through threads on this and I do not think any syntax is off, please tell me why is this not executing the script.



udev rule:



ACTION=="add", KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSserial=="C*", RUN+="/usr/bin/log-cp-usb.sh", OPTIONS="last_rule"


script log-cp-usb.sh:



rsync -av /home/pi/Downloads /media/pi/41AA-EDC6


I've tried several variations of the rule (latest addition is the OPTIONS tag) and the script runs successfully by calling it directly.Thoughts?



Update: I apologize, my script does have the #!/bin/bash at the top (I omitted because I thought it would be assumed). I've also tried #!/bin/sh and the script is in the located path destination folder, and is executable. I can go into the folder and execute the script using ./log-cp-usb.sh, using this command outside the folder returns no file present so the path should be sufficient for the rule command. @dessert I tried the latter advice to no avail It will just not run on usb insert.



Update: I've gone back to the basics and simplified the code. I'm still using a bash script that is pointed at by the udev rule.



rule:



KERNEL=="sdb1", SUBSYSTEM=="block", RUN+="/usr/bin/autocopy"



script along path /usr/bin/autocopy:



#!/bin/bash
cp -a /home/pi/Downloads/. /media/pi/41AA-EDC6/



Entering the /usr/bin directory and executing ./autocopy successfully copies the contents of the downloads folder to the designated path which is where the usb is mounted. The issue still remains that even with the created rule, the script does not run when the usb is first inserted. Advice?



Update: All scripts were made executable using chmod +x while in the file directory they were created, i.e. while in /usr/bin I executed chmod +x *script name* for both log-cp-usb.sh and autocopy. Both are independently executable using ./ command but the udev rule will not RUN+= them



Update: sudo visudo was also updated by adding pi ALL=(ALL) NOPASSWD: /usr/bin/*script name* for both autocopy and log-cp-usb.sh










share|improve this question


























  • Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

    – Sergiy Kolodyazhnyy
    Apr 16 at 15:39






  • 1





    Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

    – danzel
    Apr 16 at 16:46











  • @danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

    – Austin Michalik
    Apr 16 at 17:11












  • Unfortunately, after the change the program is still not running on usb insertion

    – Austin Michalik
    Apr 16 at 17:13











  • Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

    – WinEunuuchs2Unix
    Apr 16 at 19:41













0












0








0


1






I've spent some time running through threads on this and I do not think any syntax is off, please tell me why is this not executing the script.



udev rule:



ACTION=="add", KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSserial=="C*", RUN+="/usr/bin/log-cp-usb.sh", OPTIONS="last_rule"


script log-cp-usb.sh:



rsync -av /home/pi/Downloads /media/pi/41AA-EDC6


I've tried several variations of the rule (latest addition is the OPTIONS tag) and the script runs successfully by calling it directly.Thoughts?



Update: I apologize, my script does have the #!/bin/bash at the top (I omitted because I thought it would be assumed). I've also tried #!/bin/sh and the script is in the located path destination folder, and is executable. I can go into the folder and execute the script using ./log-cp-usb.sh, using this command outside the folder returns no file present so the path should be sufficient for the rule command. @dessert I tried the latter advice to no avail It will just not run on usb insert.



Update: I've gone back to the basics and simplified the code. I'm still using a bash script that is pointed at by the udev rule.



rule:



KERNEL=="sdb1", SUBSYSTEM=="block", RUN+="/usr/bin/autocopy"



script along path /usr/bin/autocopy:



#!/bin/bash
cp -a /home/pi/Downloads/. /media/pi/41AA-EDC6/



Entering the /usr/bin directory and executing ./autocopy successfully copies the contents of the downloads folder to the designated path which is where the usb is mounted. The issue still remains that even with the created rule, the script does not run when the usb is first inserted. Advice?



Update: All scripts were made executable using chmod +x while in the file directory they were created, i.e. while in /usr/bin I executed chmod +x *script name* for both log-cp-usb.sh and autocopy. Both are independently executable using ./ command but the udev rule will not RUN+= them



Update: sudo visudo was also updated by adding pi ALL=(ALL) NOPASSWD: /usr/bin/*script name* for both autocopy and log-cp-usb.sh










share|improve this question
















I've spent some time running through threads on this and I do not think any syntax is off, please tell me why is this not executing the script.



udev rule:



ACTION=="add", KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSserial=="C*", RUN+="/usr/bin/log-cp-usb.sh", OPTIONS="last_rule"


script log-cp-usb.sh:



rsync -av /home/pi/Downloads /media/pi/41AA-EDC6


I've tried several variations of the rule (latest addition is the OPTIONS tag) and the script runs successfully by calling it directly.Thoughts?



Update: I apologize, my script does have the #!/bin/bash at the top (I omitted because I thought it would be assumed). I've also tried #!/bin/sh and the script is in the located path destination folder, and is executable. I can go into the folder and execute the script using ./log-cp-usb.sh, using this command outside the folder returns no file present so the path should be sufficient for the rule command. @dessert I tried the latter advice to no avail It will just not run on usb insert.



Update: I've gone back to the basics and simplified the code. I'm still using a bash script that is pointed at by the udev rule.



rule:



KERNEL=="sdb1", SUBSYSTEM=="block", RUN+="/usr/bin/autocopy"



script along path /usr/bin/autocopy:



#!/bin/bash
cp -a /home/pi/Downloads/. /media/pi/41AA-EDC6/



Entering the /usr/bin directory and executing ./autocopy successfully copies the contents of the downloads folder to the designated path which is where the usb is mounted. The issue still remains that even with the created rule, the script does not run when the usb is first inserted. Advice?



Update: All scripts were made executable using chmod +x while in the file directory they were created, i.e. while in /usr/bin I executed chmod +x *script name* for both log-cp-usb.sh and autocopy. Both are independently executable using ./ command but the udev rule will not RUN+= them



Update: sudo visudo was also updated by adding pi ALL=(ALL) NOPASSWD: /usr/bin/*script name* for both autocopy and log-cp-usb.sh







scripts udev






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 16 at 19:58







Austin Michalik

















asked Apr 16 at 15:13









Austin MichalikAustin Michalik

11 bronze badge




11 bronze badge















  • Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

    – Sergiy Kolodyazhnyy
    Apr 16 at 15:39






  • 1





    Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

    – danzel
    Apr 16 at 16:46











  • @danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

    – Austin Michalik
    Apr 16 at 17:11












  • Unfortunately, after the change the program is still not running on usb insertion

    – Austin Michalik
    Apr 16 at 17:13











  • Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

    – WinEunuuchs2Unix
    Apr 16 at 19:41

















  • Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

    – Sergiy Kolodyazhnyy
    Apr 16 at 15:39






  • 1





    Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

    – danzel
    Apr 16 at 16:46











  • @danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

    – Austin Michalik
    Apr 16 at 17:11












  • Unfortunately, after the change the program is still not running on usb insertion

    – Austin Michalik
    Apr 16 at 17:13











  • Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

    – WinEunuuchs2Unix
    Apr 16 at 19:41
















Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

– Sergiy Kolodyazhnyy
Apr 16 at 15:39





Also check if the script is located in one of dirs that are in PATH variable and executable. Or just run as sh /full/path

– Sergiy Kolodyazhnyy
Apr 16 at 15:39




1




1





Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

– danzel
Apr 16 at 16:46





Did you take a look at this answer? I wonder if SUBSYSTEMS=="scsi" is correct.

– danzel
Apr 16 at 16:46













@danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

– Austin Michalik
Apr 16 at 17:11






@danzel, that got me thinking and I found that you cannot use characteristics of one device as seen from multiple parent devices in the same rule. You can only use characteristics of a device as defined by a single parent device i.e. since I used ATTRSserial, I should have used SUBSYSTEMS=="usb" as an identifier. More detail can be found here under the udevinfo section

– Austin Michalik
Apr 16 at 17:11














Unfortunately, after the change the program is still not running on usb insertion

– Austin Michalik
Apr 16 at 17:13





Unfortunately, after the change the program is still not running on usb insertion

– Austin Michalik
Apr 16 at 17:13













Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

– WinEunuuchs2Unix
Apr 16 at 19:41





Did you mark file as executable with sudo chmod a+x? This makes it executable for all users.

– WinEunuuchs2Unix
Apr 16 at 19:41










0






active

oldest

votes













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1134401%2fudev-rule-running-a-script%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1134401%2fudev-rule-running-a-script%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?