Execute command on shell command outputShell script to execute a command with iterationexecute shell script...
Why are oscilloscope input impedances so low?
How to deal with employer who keeps me at work after working hours
How can I get people to remember my character's gender?
Is any special diet an effective treatment of autism?
Why is my arithmetic with a long long int behaving this way?
Sci-fi/fantasy book - ships on steel runners skating across ice sheets
When did England stop being a Papal fief?
How to calculate rate of axial precession?
Is 'contemporary' ambiguous and if so is there a better word?
Game artist computer workstation set-up – is this overkill?
Is it normal for gliders not to have attitude indicators?
Drawing an hexagonal cone in TikZ 2D
Does running exec do anything?
As a GM, is it bad form to ask for a moment to think when improvising?
Should homeowners insurance cover the cost of the home?
Can my 2 children, aged 10 and 12, who are US citizens, travel to the USA on expired American passports?
How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?
Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?
How can a hefty sand storm happen in a thin atmosphere like Martian?
Dirichlet series with a single zero
Is there a word that describes the unjustified use of a more complex word?
Why does sound not move through a wall?
How do I allocate more memory to an app on Sheepshaver running Mac OS 9?
Why would a military not separate its forces into different branches?
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;
}
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
add a comment |
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
add a comment |
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
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
shell-script shell
asked 50 mins ago
Hwi417Hwi417
262
262
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 %s nl-terminated
sleep 1
printf 'binary1junk'
} |
while : ; do
input=$(dd bs=1G count=1 status=none)
[ "$input" ] || break
printf 'input of size %dn' "${#input}"
done
will give
input of size 17
input of size 13
input of size 11
This snippet from the standard spec may help understand dd
's behavior when used with bs=
but no ibs=
, obs=
or conv=
:
If the
bs=
expr operand is
specified and no conversions other thansync
,noerror
, ornotrunc
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 thesync
conversion is not specified, the resulting
output block shall be the same size as the input block. If thebs=
expr operand is not specified, or a conversion other thansync
,
noerror
, ornotrunc
is requested, the input shall be processed and
collected into full-sized output blocks until the end of the input
is reached.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 %s nl-terminated
sleep 1
printf 'binary1junk'
} |
while : ; do
input=$(dd bs=1G count=1 status=none)
[ "$input" ] || break
printf 'input of size %dn' "${#input}"
done
will give
input of size 17
input of size 13
input of size 11
This snippet from the standard spec may help understand dd
's behavior when used with bs=
but no ibs=
, obs=
or conv=
:
If the
bs=
expr operand is
specified and no conversions other thansync
,noerror
, ornotrunc
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 thesync
conversion is not specified, the resulting
output block shall be the same size as the input block. If thebs=
expr operand is not specified, or a conversion other thansync
,
noerror
, ornotrunc
is requested, the input shall be processed and
collected into full-sized output blocks until the end of the input
is reached.
add a comment |
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 %s nl-terminated
sleep 1
printf 'binary1junk'
} |
while : ; do
input=$(dd bs=1G count=1 status=none)
[ "$input" ] || break
printf 'input of size %dn' "${#input}"
done
will give
input of size 17
input of size 13
input of size 11
This snippet from the standard spec may help understand dd
's behavior when used with bs=
but no ibs=
, obs=
or conv=
:
If the
bs=
expr operand is
specified and no conversions other thansync
,noerror
, ornotrunc
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 thesync
conversion is not specified, the resulting
output block shall be the same size as the input block. If thebs=
expr operand is not specified, or a conversion other thansync
,
noerror
, ornotrunc
is requested, the input shall be processed and
collected into full-sized output blocks until the end of the input
is reached.
add a comment |
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 %s nl-terminated
sleep 1
printf 'binary1junk'
} |
while : ; do
input=$(dd bs=1G count=1 status=none)
[ "$input" ] || break
printf 'input of size %dn' "${#input}"
done
will give
input of size 17
input of size 13
input of size 11
This snippet from the standard spec may help understand dd
's behavior when used with bs=
but no ibs=
, obs=
or conv=
:
If the
bs=
expr operand is
specified and no conversions other thansync
,noerror
, ornotrunc
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 thesync
conversion is not specified, the resulting
output block shall be the same size as the input block. If thebs=
expr operand is not specified, or a conversion other thansync
,
noerror
, ornotrunc
is requested, the input shall be processed and
collected into full-sized output blocks until the end of the input
is reached.
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 %s nl-terminated
sleep 1
printf 'binary1junk'
} |
while : ; do
input=$(dd bs=1G count=1 status=none)
[ "$input" ] || break
printf 'input of size %dn' "${#input}"
done
will give
input of size 17
input of size 13
input of size 11
This snippet from the standard spec may help understand dd
's behavior when used with bs=
but no ibs=
, obs=
or conv=
:
If the
bs=
expr operand is
specified and no conversions other thansync
,noerror
, ornotrunc
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 thesync
conversion is not specified, the resulting
output block shall be the same size as the input block. If thebs=
expr operand is not specified, or a conversion other thansync
,
noerror
, ornotrunc
is requested, the input shall be processed and
collected into full-sized output blocks until the end of the input
is reached.
edited 43 secs ago
answered 6 mins ago
mosvymosvy
11.1k11340
11.1k11340
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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