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 to pass hash as password to ssh server

Sparring against two opponents test

no sense/need/point

Should I simplify my writing in a foreign country?

about academic proof-reading, what to do in this situation?

What do you call a painting on a wall?

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?

When did England stop being a Papal fief?

Looking for sci-fi book based on Hinduism/Buddhism

Execute command on shell command output

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

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

Is it normal for gliders not to have attitude indicators?

Where are the "shires" in the UK?

What's the 2-minute timer on mobile Deutsche Bahn tickets?

Has the United States ever had a non-Christian President?

Determine if a grid contains another grid

Clarification of algebra in moment generating functions

Would a "Permanence" spell in 5e be overpowered?

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

Dihedral group D4 composition with custom labels

In Futurama, how many beings has Leela slept with?

Make me a minimum magic sum

Dangerous workplace travelling



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 %s 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
            3 mins ago











          • yes, thanks for the correction.

            – mosvy
            49 secs 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 %s 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
            3 mins ago











          • yes, thanks for the correction.

            – mosvy
            49 secs 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 %s 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
            3 mins ago











          • yes, thanks for the correction.

            – mosvy
            49 secs 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 %s 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 %s 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 3 mins ago

























          answered 35 mins ago









          mosvymosvy

          11.1k11340




          11.1k11340












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

            – iruvar
            3 mins ago











          • yes, thanks for the correction.

            – mosvy
            49 secs ago

















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

            – iruvar
            3 mins ago











          • yes, thanks for the correction.

            – mosvy
            49 secs ago
















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

          – iruvar
          3 mins ago





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

          – iruvar
          3 mins ago













          yes, thanks for the correction.

          – mosvy
          49 secs ago





          yes, thanks for the correction.

          – mosvy
          49 secs 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

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單