udev: communicate between two rules The 2019 Stack Overflow Developer Survey Results Are In ...

Could an empire control the whole planet with today's comunication methods?

1960s short story making fun of James Bond-style spy fiction

Do warforged have souls?

Identify 80s or 90s comics with ripped creatures (not dwarves)

Do I have Disadvantage attacking with an off-hand weapon?

Can I visit the Trinity College (Cambridge) library and see some of their rare books

US Healthcare consultation for visitors

First use of “packing” as in carrying a gun

Simulating Exploding Dice

Are spiders unable to hurt humans, especially very small spiders?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

should truth entail possible truth

What information about me do stores get via my credit card?

How to support a colleague who finds meetings extremely tiring?

"is" operation returns false even though two objects have same id

Windows 10: How to Lock (not sleep) laptop on lid close?

Does Parliament hold absolute power in the UK?

Can a flute soloist sit?

Mortgage adviser recommends a longer term than necessary combined with overpayments

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

What is the role of 'For' here?

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Sub-subscripts in strings cause different spacings than subscripts

Can the Right Ascension and Argument of Perigee of a spacecraft's orbit keep varying by themselves with time?



udev: communicate between two rules



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraScript in udev rule doesn’t runudev rule to auto load keyboard layout when usb keyboard plugged inReloading udev rules failsWriting udev rulesUdev rules on Ubuntu/OMAP (Beaglebone)Udev rules failing to pass parametersudev rules ignore_deviceudev rules exclude deviceHow can I automatically format and write data to an SD card when it is plugged in? (Trigger systemd service on change rather than add.)why udev does not trigger remove event for mounted sdcard partitions?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Is there a simple way to communicate between two different rules,
one for the ADD event, the other for the BIND event on the same device?



The ADD rule is executed first, afterwards comes the BIND rule. I would like to change how my BIND rule behaves, based on a variable set by the ADD rule.



What I tried so far:





  • I tried to use ENV{variable}="1" at the ADD rule and matching against it at the BIND rule using ENV{variable}=="1". Unfortunately this variable is not available in the BIND rule anymore, looks like the lifetime of those ENV variables is limited to only those rules on the same device and the same action (therefore only ADD rules).



    ACTION=="add", ENV{MODALIAS}=="abc", 
    ENV{variable}="1"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    ENV{variable}=="1"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    ENV{variable}=="2"


    I always thought that ENV variables are available everywhere in udev, but this seems to be wrong...




  • I also tried to set ATTR{foo}="bar" in the ADD rule and matching against it in the BIND rule using ATTRS{foo}=="bar". Doesn't work either.



    ACTION=="add", ENV{MODALIAS}=="abc", 
    ATTR{variable}="1"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    ATTRS{variable}=="1"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    ATTRS{variable}=="2"


    I have no idea why this doesn't work.








  • The only way that works so far is to echo the value of the variable into a file in the ADD rule (using RUN) and read it out in the BIND rule using PROGRAM and RESULT.



    ACTION=="add", ENV{MODALIAS}=="abc", 
    RUN+="/bin/bash -c 'echo "1" > /etc/udev/rules.d/variable'"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
    RESULT=="1"

    ACTION=="bind", ENV{MODALIAS}=="abc",
    PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
    RESULT=="2"



Any other ideas?










share|improve this question































    0















    Is there a simple way to communicate between two different rules,
    one for the ADD event, the other for the BIND event on the same device?



    The ADD rule is executed first, afterwards comes the BIND rule. I would like to change how my BIND rule behaves, based on a variable set by the ADD rule.



    What I tried so far:





    • I tried to use ENV{variable}="1" at the ADD rule and matching against it at the BIND rule using ENV{variable}=="1". Unfortunately this variable is not available in the BIND rule anymore, looks like the lifetime of those ENV variables is limited to only those rules on the same device and the same action (therefore only ADD rules).



      ACTION=="add", ENV{MODALIAS}=="abc", 
      ENV{variable}="1"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      ENV{variable}=="1"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      ENV{variable}=="2"


      I always thought that ENV variables are available everywhere in udev, but this seems to be wrong...




    • I also tried to set ATTR{foo}="bar" in the ADD rule and matching against it in the BIND rule using ATTRS{foo}=="bar". Doesn't work either.



      ACTION=="add", ENV{MODALIAS}=="abc", 
      ATTR{variable}="1"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      ATTRS{variable}=="1"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      ATTRS{variable}=="2"


      I have no idea why this doesn't work.








    • The only way that works so far is to echo the value of the variable into a file in the ADD rule (using RUN) and read it out in the BIND rule using PROGRAM and RESULT.



      ACTION=="add", ENV{MODALIAS}=="abc", 
      RUN+="/bin/bash -c 'echo "1" > /etc/udev/rules.d/variable'"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
      RESULT=="1"

      ACTION=="bind", ENV{MODALIAS}=="abc",
      PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
      RESULT=="2"



    Any other ideas?










    share|improve this question



























      0












      0








      0








      Is there a simple way to communicate between two different rules,
      one for the ADD event, the other for the BIND event on the same device?



      The ADD rule is executed first, afterwards comes the BIND rule. I would like to change how my BIND rule behaves, based on a variable set by the ADD rule.



      What I tried so far:





      • I tried to use ENV{variable}="1" at the ADD rule and matching against it at the BIND rule using ENV{variable}=="1". Unfortunately this variable is not available in the BIND rule anymore, looks like the lifetime of those ENV variables is limited to only those rules on the same device and the same action (therefore only ADD rules).



        ACTION=="add", ENV{MODALIAS}=="abc", 
        ENV{variable}="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ENV{variable}=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ENV{variable}=="2"


        I always thought that ENV variables are available everywhere in udev, but this seems to be wrong...




      • I also tried to set ATTR{foo}="bar" in the ADD rule and matching against it in the BIND rule using ATTRS{foo}=="bar". Doesn't work either.



        ACTION=="add", ENV{MODALIAS}=="abc", 
        ATTR{variable}="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ATTRS{variable}=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ATTRS{variable}=="2"


        I have no idea why this doesn't work.








      • The only way that works so far is to echo the value of the variable into a file in the ADD rule (using RUN) and read it out in the BIND rule using PROGRAM and RESULT.



        ACTION=="add", ENV{MODALIAS}=="abc", 
        RUN+="/bin/bash -c 'echo "1" > /etc/udev/rules.d/variable'"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
        RESULT=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
        RESULT=="2"



      Any other ideas?










      share|improve this question
















      Is there a simple way to communicate between two different rules,
      one for the ADD event, the other for the BIND event on the same device?



      The ADD rule is executed first, afterwards comes the BIND rule. I would like to change how my BIND rule behaves, based on a variable set by the ADD rule.



      What I tried so far:





      • I tried to use ENV{variable}="1" at the ADD rule and matching against it at the BIND rule using ENV{variable}=="1". Unfortunately this variable is not available in the BIND rule anymore, looks like the lifetime of those ENV variables is limited to only those rules on the same device and the same action (therefore only ADD rules).



        ACTION=="add", ENV{MODALIAS}=="abc", 
        ENV{variable}="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ENV{variable}=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ENV{variable}=="2"


        I always thought that ENV variables are available everywhere in udev, but this seems to be wrong...




      • I also tried to set ATTR{foo}="bar" in the ADD rule and matching against it in the BIND rule using ATTRS{foo}=="bar". Doesn't work either.



        ACTION=="add", ENV{MODALIAS}=="abc", 
        ATTR{variable}="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ATTRS{variable}=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        ATTRS{variable}=="2"


        I have no idea why this doesn't work.








      • The only way that works so far is to echo the value of the variable into a file in the ADD rule (using RUN) and read it out in the BIND rule using PROGRAM and RESULT.



        ACTION=="add", ENV{MODALIAS}=="abc", 
        RUN+="/bin/bash -c 'echo "1" > /etc/udev/rules.d/variable'"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
        RESULT=="1"

        ACTION=="bind", ENV{MODALIAS}=="abc",
        PROGRAM="/bin/bash -c 'cat /etc/udev/rules.d/variable'",
        RESULT=="2"



      Any other ideas?







      udev






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      tollo

















      asked yesterday









      tollotollo

      1457




      1457






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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/3.0/"u003ecc by-sa 3.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%2fsuperuser.com%2fquestions%2f1424242%2fudev-communicate-between-two-rules%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 Super User!


          • 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%2fsuperuser.com%2fquestions%2f1424242%2fudev-communicate-between-two-rules%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

          Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...