Linux scripting - how do I wait for CD/DVD medium to load before reading/mounting?

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











up vote
0
down vote

favorite
1












I'm putting together a quick-and-dirty script to help me read 100s of CD/DVDs onto a NAS. It takes care of ejecting and loading the tray, but I haven't figured out a simple way to wait/block for the medium to become available to the OS after inserting the tray.




  • eject -t exits as soon as the tray closes


  • mount will fail with No medium found if it's run immediately after eject, but also when it's run 15 seconds later.

The discs are fairly old and some take considerable time to become available, so I'd like to avoid the "sleep for 2 minutes" non-solution. Any ideas? Using ubuntu 18.04.









share

























    up vote
    0
    down vote

    favorite
    1












    I'm putting together a quick-and-dirty script to help me read 100s of CD/DVDs onto a NAS. It takes care of ejecting and loading the tray, but I haven't figured out a simple way to wait/block for the medium to become available to the OS after inserting the tray.




    • eject -t exits as soon as the tray closes


    • mount will fail with No medium found if it's run immediately after eject, but also when it's run 15 seconds later.

    The discs are fairly old and some take considerable time to become available, so I'd like to avoid the "sleep for 2 minutes" non-solution. Any ideas? Using ubuntu 18.04.









    share























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I'm putting together a quick-and-dirty script to help me read 100s of CD/DVDs onto a NAS. It takes care of ejecting and loading the tray, but I haven't figured out a simple way to wait/block for the medium to become available to the OS after inserting the tray.




      • eject -t exits as soon as the tray closes


      • mount will fail with No medium found if it's run immediately after eject, but also when it's run 15 seconds later.

      The discs are fairly old and some take considerable time to become available, so I'd like to avoid the "sleep for 2 minutes" non-solution. Any ideas? Using ubuntu 18.04.









      share













      I'm putting together a quick-and-dirty script to help me read 100s of CD/DVDs onto a NAS. It takes care of ejecting and loading the tray, but I haven't figured out a simple way to wait/block for the medium to become available to the OS after inserting the tray.




      • eject -t exits as soon as the tray closes


      • mount will fail with No medium found if it's run immediately after eject, but also when it's run 15 seconds later.

      The discs are fairly old and some take considerable time to become available, so I'd like to avoid the "sleep for 2 minutes" non-solution. Any ideas? Using ubuntu 18.04.







      bash shell optical-media





      share












      share










      share



      share










      asked 1 min ago









      myxal

      286




      286

























          active

          oldest

          votes











          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%2f477577%2flinux-scripting-how-do-i-wait-for-cd-dvd-medium-to-load-before-reading-mountin%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477577%2flinux-scripting-how-do-i-wait-for-cd-dvd-medium-to-load-before-reading-mountin%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos