Execute command on shell command outputShell script to execute a command with iterationexecute shell script optionsShell script to execute psql commandBash: move files of specific patternExecute command on multiple severs in parallel using shell scripttimeout causes while read loop to end when `cat` is timed outShell script to ls and execute command on ls resultExecute command without terminal outputHow to write a function that reliably exits (with a specified status) the current process?Execute python file from shell script based on the cat/awk output

How did the Apollo guidance computer handle parity bit errors?

Does running exec do anything?

Is there a word for food that's gone 'bad', but is still edible?

How can a hefty sand storm happen in a thin atmosphere like Martian?

Why didn't this character get a funeral at the end of Avengers: Endgame?

It isn’t that you must stop now

Meaning of the (idiomatic?) expression "seghe mentali"

How to preserve a rare version of a book?

Why did WWI include Japan?

Krull dimension of the ring of global sections

Dihedral group D4 composition with custom labels

Will a God Eternal enchanted with Deep Freeze shuffle back into the deck if it dies?

The origin of list data structure

Clarification of algebra in moment generating functions

What happens if I accidentally leave an app running and click "Install Now" in Software Updater?

Where are the "shires" in the UK?

Should homeowners insurance cover the cost of the home?

What do you call a painting on a wall?

How can Internet speed be 10 times slower without a router than when using the same connection with a router?

In Futurama, how many beings has Leela slept with?

What is a common way to tell if an academic is "above average," or outstanding in their field? Is their h-index (Hirsh index) one of them?

Game artist computer workstation set-up – is this overkill?

Make me a minimum magic sum

How to calculate rate of axial precession?



Execute command on shell command output


Shell script to execute a command with iterationexecute shell script optionsShell script to execute psql commandBash: move files of specific patternExecute command on multiple severs in parallel using shell scripttimeout causes while read loop to end when `cat` is timed outShell script to ls and execute command on ls resultExecute command without terminal outputHow to write a function that reliably exits (with a specified status) the current process?Execute python file from shell script based on the cat/awk output






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








1















I have a command that runs forever and periodically output stuff until it gets killed by something else (similar to tail -f), and I want to make it so that whenever there's new output another command gets executed.



Caveats:



  • I can't use Bash

  • That command obviously isn't tail, it just behaves in a similar manner

  • That command's output doesn't always come in lines, and I do not intend to execute that other command for each line of the output

  • Polling is not an acceptable solution









share|improve this question




























    1















    I have a command that runs forever and periodically output stuff until it gets killed by something else (similar to tail -f), and I want to make it so that whenever there's new output another command gets executed.



    Caveats:



    • I can't use Bash

    • That command obviously isn't tail, it just behaves in a similar manner

    • That command's output doesn't always come in lines, and I do not intend to execute that other command for each line of the output

    • Polling is not an acceptable solution









    share|improve this question
























      1












      1








      1








      I have a command that runs forever and periodically output stuff until it gets killed by something else (similar to tail -f), and I want to make it so that whenever there's new output another command gets executed.



      Caveats:



      • I can't use Bash

      • That command obviously isn't tail, it just behaves in a similar manner

      • That command's output doesn't always come in lines, and I do not intend to execute that other command for each line of the output

      • Polling is not an acceptable solution









      share|improve this question














      I have a command that runs forever and periodically output stuff until it gets killed by something else (similar to tail -f), and I want to make it so that whenever there's new output another command gets executed.



      Caveats:



      • I can't use Bash

      • That command obviously isn't tail, it just behaves in a similar manner

      • That command's output doesn't always come in lines, and I do not intend to execute that other command for each line of the output

      • Polling is not an acceptable solution






      shell-script shell






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Hwi417Hwi417

      312




      312




















          1 Answer
          1






          active

          oldest

          votes


















          2














          Here is an example of using dd to trigger a shell command whenever something is read from stdin, whether terminated by newline or not:




          printf not-nl-terminated
          sleep 1
          printf '%sn' nl-terminated
          sleep 1
          printf 'other1junk'
          |
          while : ; do
          input=$(dd bs=1G count=1 2>/dev/null)
          [ "$input" ] || break
          printf 'input of size %dn' "$#input"
          done


          will give



          input of size 17
          input of size 13
          input of size 10


          This snippet from the standard spec may help understand dd's behavior when bs= is used explicily:




          If the bs= expr operand is
          specified and no conversions other than sync, noerror, or notrunc
          are requested, the data returned from each input block shall be
          written as a separate output block; if the read returns less than a
          full block
          and the sync conversion is not specified, the resulting
          output block shall be the same size as the input block. If the bs=
          expr operand is not specified, or a conversion other than sync,
          noerror, or notrunc is requested, the input shall be processed and
          collected into full-sized output blocks until the end of the input
          is reached.




          Note:



          If the input data may contain NUL bytes, you may want something like



          input=$(dd bs=1G count=1 2>/dev/null | tr '' _)


          or parse the status lines that dd writes to stderr.






          share|improve this answer

























          • did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

            – iruvar
            4 mins ago











          • yes, thanks for the correction.

            – mosvy
            2 mins ago











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f517168%2fexecute-command-on-shell-command-output%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Here is an example of using dd to trigger a shell command whenever something is read from stdin, whether terminated by newline or not:




          printf not-nl-terminated
          sleep 1
          printf '%sn' nl-terminated
          sleep 1
          printf 'other1junk'
          |
          while : ; do
          input=$(dd bs=1G count=1 2>/dev/null)
          [ "$input" ] || break
          printf 'input of size %dn' "$#input"
          done


          will give



          input of size 17
          input of size 13
          input of size 10


          This snippet from the standard spec may help understand dd's behavior when bs= is used explicily:




          If the bs= expr operand is
          specified and no conversions other than sync, noerror, or notrunc
          are requested, the data returned from each input block shall be
          written as a separate output block; if the read returns less than a
          full block
          and the sync conversion is not specified, the resulting
          output block shall be the same size as the input block. If the bs=
          expr operand is not specified, or a conversion other than sync,
          noerror, or notrunc is requested, the input shall be processed and
          collected into full-sized output blocks until the end of the input
          is reached.




          Note:



          If the input data may contain NUL bytes, you may want something like



          input=$(dd bs=1G count=1 2>/dev/null | tr '' _)


          or parse the status lines that dd writes to stderr.






          share|improve this answer

























          • did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

            – iruvar
            4 mins ago











          • yes, thanks for the correction.

            – mosvy
            2 mins ago















          2














          Here is an example of using dd to trigger a shell command whenever something is read from stdin, whether terminated by newline or not:




          printf not-nl-terminated
          sleep 1
          printf '%sn' nl-terminated
          sleep 1
          printf 'other1junk'
          |
          while : ; do
          input=$(dd bs=1G count=1 2>/dev/null)
          [ "$input" ] || break
          printf 'input of size %dn' "$#input"
          done


          will give



          input of size 17
          input of size 13
          input of size 10


          This snippet from the standard spec may help understand dd's behavior when bs= is used explicily:




          If the bs= expr operand is
          specified and no conversions other than sync, noerror, or notrunc
          are requested, the data returned from each input block shall be
          written as a separate output block; if the read returns less than a
          full block
          and the sync conversion is not specified, the resulting
          output block shall be the same size as the input block. If the bs=
          expr operand is not specified, or a conversion other than sync,
          noerror, or notrunc is requested, the input shall be processed and
          collected into full-sized output blocks until the end of the input
          is reached.




          Note:



          If the input data may contain NUL bytes, you may want something like



          input=$(dd bs=1G count=1 2>/dev/null | tr '' _)


          or parse the status lines that dd writes to stderr.






          share|improve this answer

























          • did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

            – iruvar
            4 mins ago











          • yes, thanks for the correction.

            – mosvy
            2 mins ago













          2












          2








          2







          Here is an example of using dd to trigger a shell command whenever something is read from stdin, whether terminated by newline or not:




          printf not-nl-terminated
          sleep 1
          printf '%sn' nl-terminated
          sleep 1
          printf 'other1junk'
          |
          while : ; do
          input=$(dd bs=1G count=1 2>/dev/null)
          [ "$input" ] || break
          printf 'input of size %dn' "$#input"
          done


          will give



          input of size 17
          input of size 13
          input of size 10


          This snippet from the standard spec may help understand dd's behavior when bs= is used explicily:




          If the bs= expr operand is
          specified and no conversions other than sync, noerror, or notrunc
          are requested, the data returned from each input block shall be
          written as a separate output block; if the read returns less than a
          full block
          and the sync conversion is not specified, the resulting
          output block shall be the same size as the input block. If the bs=
          expr operand is not specified, or a conversion other than sync,
          noerror, or notrunc is requested, the input shall be processed and
          collected into full-sized output blocks until the end of the input
          is reached.




          Note:



          If the input data may contain NUL bytes, you may want something like



          input=$(dd bs=1G count=1 2>/dev/null | tr '' _)


          or parse the status lines that dd writes to stderr.






          share|improve this answer















          Here is an example of using dd to trigger a shell command whenever something is read from stdin, whether terminated by newline or not:




          printf not-nl-terminated
          sleep 1
          printf '%sn' nl-terminated
          sleep 1
          printf 'other1junk'
          |
          while : ; do
          input=$(dd bs=1G count=1 2>/dev/null)
          [ "$input" ] || break
          printf 'input of size %dn' "$#input"
          done


          will give



          input of size 17
          input of size 13
          input of size 10


          This snippet from the standard spec may help understand dd's behavior when bs= is used explicily:




          If the bs= expr operand is
          specified and no conversions other than sync, noerror, or notrunc
          are requested, the data returned from each input block shall be
          written as a separate output block; if the read returns less than a
          full block
          and the sync conversion is not specified, the resulting
          output block shall be the same size as the input block. If the bs=
          expr operand is not specified, or a conversion other than sync,
          noerror, or notrunc is requested, the input shall be processed and
          collected into full-sized output blocks until the end of the input
          is reached.




          Note:



          If the input data may contain NUL bytes, you may want something like



          input=$(dd bs=1G count=1 2>/dev/null | tr '' _)


          or parse the status lines that dd writes to stderr.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 4 mins ago

























          answered 36 mins ago









          mosvymosvy

          11.1k11340




          11.1k11340












          • did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

            – iruvar
            4 mins ago











          • yes, thanks for the correction.

            – mosvy
            2 mins ago

















          • did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

            – iruvar
            4 mins ago











          • yes, thanks for the correction.

            – mosvy
            2 mins ago
















          did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

          – iruvar
          4 mins ago





          did you mean printf '%sn' nl-terminated in stead of printf %s nl-terminated?

          – iruvar
          4 mins ago













          yes, thanks for the correction.

          – mosvy
          2 mins ago





          yes, thanks for the correction.

          – mosvy
          2 mins ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f517168%2fexecute-command-on-shell-command-output%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

          Log på Navigationsmenu

          Creating second map without labels using QGIS?How to lock map labels for inset map in Print Composer?How to Force the Showing of Labels of a Vector File in QGISQGIS Valmiera, Labels only show for part of polygonsRemoving duplicate point labels in QGISLabeling every feature using QGIS?Show labels for point features outside map canvasAbbreviate Road Labels in QGIS only when requiredExporting map from composer in QGIS - text labels have moved in output?How to make sure labels in qgis turn up in layout map?Writing label expression with ArcMap and If then Statement?

          Nuuk Indholdsfortegnelse Etyomologi | Historie | Geografi | Transport og infrastruktur | Politik og administration | Uddannelsesinstitutioner | Kultur | Venskabsbyer | Noter | Eksterne henvisninger | Se også | Navigationsmenuwww.sermersooq.gl64°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.75064°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.750DMI - KlimanormalerSalmonsen, s. 850Grønlands Naturinstitut undersøger rensdyr i Akia og Maniitsoq foråret 2008Grønlands NaturinstitutNy vej til Qinngorput indviet i dagAntallet af biler i Nuuk må begrænsesNy taxacentral mødt med demonstrationKøreplan. Rute 1, 2 og 3SnescootersporNuukNord er for storSkoler i Kommuneqarfik SermersooqAtuarfik Samuel KleinschmidtKangillinguit AtuarfiatNuussuup AtuarfiaNuuk Internationale FriskoleIlinniarfissuaq, Grønlands SeminariumLedelseÅrsberetning for 2008Kunst og arkitekturÅrsberetning for 2008Julie om naturenNuuk KunstmuseumSilamiutGrønlands Nationalmuseum og ArkivStatistisk ÅrbogGrønlands LandsbibliotekStore koncerter på stribeVandhund nummer 1.000.000Kommuneqarfik Sermersooq – MalikForsidenVenskabsbyerLyngby-Taarbæk i GrønlandArctic Business NetworkWinter Cities 2008 i NuukDagligt opdaterede satellitbilleder fra NuukområdetKommuneqarfik Sermersooqs hjemmesideTurist i NuukGrønlands Statistiks databankGrønlands Hjemmestyres valgresultaterrrWorldCat124325457671310-5