udev ACTION add isn't working

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to use udev for some basic actions, in this case the idea is to launch a simple script. The problem is that when I use this rule:



ACTION=="remove", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


It runs perfect, but if I use this one:



ACTION=="add", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


No action is done! I'm trying to trigger an action when an usb with a label "NAMEHERE" is connected, NOT disconnected.










share|improve this question























  • Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
    – dirkt
    Sep 13 at 12:24










  • First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
    – Brokes
    Sep 13 at 12:26














up vote
0
down vote

favorite












I'm trying to use udev for some basic actions, in this case the idea is to launch a simple script. The problem is that when I use this rule:



ACTION=="remove", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


It runs perfect, but if I use this one:



ACTION=="add", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


No action is done! I'm trying to trigger an action when an usb with a label "NAMEHERE" is connected, NOT disconnected.










share|improve this question























  • Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
    – dirkt
    Sep 13 at 12:24










  • First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
    – Brokes
    Sep 13 at 12:26












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to use udev for some basic actions, in this case the idea is to launch a simple script. The problem is that when I use this rule:



ACTION=="remove", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


It runs perfect, but if I use this one:



ACTION=="add", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


No action is done! I'm trying to trigger an action when an usb with a label "NAMEHERE" is connected, NOT disconnected.










share|improve this question















I'm trying to use udev for some basic actions, in this case the idea is to launch a simple script. The problem is that when I use this rule:



ACTION=="remove", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


It runs perfect, but if I use this one:



ACTION=="add", ENVID_FS_LABEL=="NAMEHERE", KERNEL=="sd[a-z][0-9]", RUN+="/home/foobar/Scrapyard/the_script.sh"


No action is done! I'm trying to trigger an action when an usb with a label "NAMEHERE" is connected, NOT disconnected.







linux kernel usb udev devices






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 16 at 23:31









Jeff Schaller

33.1k849111




33.1k849111










asked Sep 13 at 12:17









Brokes

111




111











  • Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
    – dirkt
    Sep 13 at 12:24










  • First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
    – Brokes
    Sep 13 at 12:26
















  • Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
    – dirkt
    Sep 13 at 12:24










  • First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
    – Brokes
    Sep 13 at 12:26















Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
– dirkt
Sep 13 at 12:24




Quick shot: It may not have the ID_FS_LABEL at the point where you are calling the rule, because it will need to run some other rule (calling blkid or whatever, can't remember) to determine the label in the first place.
– dirkt
Sep 13 at 12:24












First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
– Brokes
Sep 13 at 12:26




First at all, thanks for your time dirkt... blkid os similar before using this rule maybe?
– Brokes
Sep 13 at 12:26










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Now, with some extra research, the problem fixed or at least I think so:



# If not an usb... End the execution
KERNEL!="sd[a-z][0-9]", GOTO="media_mount_end"
# Import FS infos
IMPORTprogram="/sbin/blkid -o udev -p %N"
ACTION=="add", ENVID_FS_LABEL=="PERAMA", RUN+="/home/gizquierdo/Scrapyard/elScriptejo.sh"
LABEL="media_mount_end"





share|improve this answer


















  • 1




    I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
    – dirkt
    Sep 13 at 13:28










  • Perfect, thanks dirkt!
    – Brokes
    Sep 13 at 13:59










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468783%2fudev-action-add-isnt-working%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Now, with some extra research, the problem fixed or at least I think so:



# If not an usb... End the execution
KERNEL!="sd[a-z][0-9]", GOTO="media_mount_end"
# Import FS infos
IMPORTprogram="/sbin/blkid -o udev -p %N"
ACTION=="add", ENVID_FS_LABEL=="PERAMA", RUN+="/home/gizquierdo/Scrapyard/elScriptejo.sh"
LABEL="media_mount_end"





share|improve this answer


















  • 1




    I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
    – dirkt
    Sep 13 at 13:28










  • Perfect, thanks dirkt!
    – Brokes
    Sep 13 at 13:59














up vote
1
down vote













Now, with some extra research, the problem fixed or at least I think so:



# If not an usb... End the execution
KERNEL!="sd[a-z][0-9]", GOTO="media_mount_end"
# Import FS infos
IMPORTprogram="/sbin/blkid -o udev -p %N"
ACTION=="add", ENVID_FS_LABEL=="PERAMA", RUN+="/home/gizquierdo/Scrapyard/elScriptejo.sh"
LABEL="media_mount_end"





share|improve this answer


















  • 1




    I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
    – dirkt
    Sep 13 at 13:28










  • Perfect, thanks dirkt!
    – Brokes
    Sep 13 at 13:59












up vote
1
down vote










up vote
1
down vote









Now, with some extra research, the problem fixed or at least I think so:



# If not an usb... End the execution
KERNEL!="sd[a-z][0-9]", GOTO="media_mount_end"
# Import FS infos
IMPORTprogram="/sbin/blkid -o udev -p %N"
ACTION=="add", ENVID_FS_LABEL=="PERAMA", RUN+="/home/gizquierdo/Scrapyard/elScriptejo.sh"
LABEL="media_mount_end"





share|improve this answer














Now, with some extra research, the problem fixed or at least I think so:



# If not an usb... End the execution
KERNEL!="sd[a-z][0-9]", GOTO="media_mount_end"
# Import FS infos
IMPORTprogram="/sbin/blkid -o udev -p %N"
ACTION=="add", ENVID_FS_LABEL=="PERAMA", RUN+="/home/gizquierdo/Scrapyard/elScriptejo.sh"
LABEL="media_mount_end"






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 16 at 23:32









Jeff Schaller

33.1k849111




33.1k849111










answered Sep 13 at 12:34









Brokes

111




111







  • 1




    I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
    – dirkt
    Sep 13 at 13:28










  • Perfect, thanks dirkt!
    – Brokes
    Sep 13 at 13:59












  • 1




    I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
    – dirkt
    Sep 13 at 13:28










  • Perfect, thanks dirkt!
    – Brokes
    Sep 13 at 13:59







1




1




I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
– dirkt
Sep 13 at 13:28




I guess a cleaner solution would be to let the other rule which does blkid anyway run first, or it'll get run twice... but that means you'll need to find out which rule this is. But if you don't mind the extra overhead, do whatever works for you.
– dirkt
Sep 13 at 13:28












Perfect, thanks dirkt!
– Brokes
Sep 13 at 13:59




Perfect, thanks dirkt!
– Brokes
Sep 13 at 13:59

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468783%2fudev-action-add-isnt-working%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?