How's the right way to pipe stdout & stderr from ping into an awk program? [duplicate]
This question already has an answer here:
Piping both stdout and stderr in bash?
2 answers
Here's an excerpt of some commands that I've been trying to evaluate from a Zsh script:
cmd="ping -qc 3 -W 5 8.8.8.8 | xargs -0d 'n' awk -f presetup/testping.awk 2>&1"
print -r ${cmd}
output=$(eval ${cmd})
print ${output}
I don't know what I'm missing but, all I'm trying to do is to process the stderr & stdout of ping with a single awk script. Here's the output I'm getting:
awk: presetup/testping.awk:6: fatal: cannot open file `PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.' for reading (No such file or directory)
The program is supposed to parse each output line of the ping command and match with regular expressions its output. Any ideas of what I'm missing?
awk zsh xargs
marked as duplicate by tripleee, Community♦ Nov 16 at 1:00
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Piping both stdout and stderr in bash?
2 answers
Here's an excerpt of some commands that I've been trying to evaluate from a Zsh script:
cmd="ping -qc 3 -W 5 8.8.8.8 | xargs -0d 'n' awk -f presetup/testping.awk 2>&1"
print -r ${cmd}
output=$(eval ${cmd})
print ${output}
I don't know what I'm missing but, all I'm trying to do is to process the stderr & stdout of ping with a single awk script. Here's the output I'm getting:
awk: presetup/testping.awk:6: fatal: cannot open file `PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.' for reading (No such file or directory)
The program is supposed to parse each output line of the ping command and match with regular expressions its output. Any ideas of what I'm missing?
awk zsh xargs
marked as duplicate by tripleee, Community♦ Nov 16 at 1:00
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
xargs
is wrong there, you have to pipe stdout and stderr toawk
.
– karakfa
Nov 13 at 19:09
@karakfa, thanks for your input. I removedxargs
and tried this:ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output:ping: -: Name or service not known
.
– ScutulatIum
Nov 13 at 21:41
@karakfa, nevermind, I found it. The right way seems to be the following:ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!
– ScutulatIum
Nov 13 at 21:48
add a comment |
This question already has an answer here:
Piping both stdout and stderr in bash?
2 answers
Here's an excerpt of some commands that I've been trying to evaluate from a Zsh script:
cmd="ping -qc 3 -W 5 8.8.8.8 | xargs -0d 'n' awk -f presetup/testping.awk 2>&1"
print -r ${cmd}
output=$(eval ${cmd})
print ${output}
I don't know what I'm missing but, all I'm trying to do is to process the stderr & stdout of ping with a single awk script. Here's the output I'm getting:
awk: presetup/testping.awk:6: fatal: cannot open file `PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.' for reading (No such file or directory)
The program is supposed to parse each output line of the ping command and match with regular expressions its output. Any ideas of what I'm missing?
awk zsh xargs
This question already has an answer here:
Piping both stdout and stderr in bash?
2 answers
Here's an excerpt of some commands that I've been trying to evaluate from a Zsh script:
cmd="ping -qc 3 -W 5 8.8.8.8 | xargs -0d 'n' awk -f presetup/testping.awk 2>&1"
print -r ${cmd}
output=$(eval ${cmd})
print ${output}
I don't know what I'm missing but, all I'm trying to do is to process the stderr & stdout of ping with a single awk script. Here's the output I'm getting:
awk: presetup/testping.awk:6: fatal: cannot open file `PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.' for reading (No such file or directory)
The program is supposed to parse each output line of the ping command and match with regular expressions its output. Any ideas of what I'm missing?
This question already has an answer here:
Piping both stdout and stderr in bash?
2 answers
awk zsh xargs
awk zsh xargs
edited Nov 13 at 21:58
asked Nov 13 at 18:09
ScutulatIum
13
13
marked as duplicate by tripleee, Community♦ Nov 16 at 1:00
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by tripleee, Community♦ Nov 16 at 1:00
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
xargs
is wrong there, you have to pipe stdout and stderr toawk
.
– karakfa
Nov 13 at 19:09
@karakfa, thanks for your input. I removedxargs
and tried this:ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output:ping: -: Name or service not known
.
– ScutulatIum
Nov 13 at 21:41
@karakfa, nevermind, I found it. The right way seems to be the following:ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!
– ScutulatIum
Nov 13 at 21:48
add a comment |
2
xargs
is wrong there, you have to pipe stdout and stderr toawk
.
– karakfa
Nov 13 at 19:09
@karakfa, thanks for your input. I removedxargs
and tried this:ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output:ping: -: Name or service not known
.
– ScutulatIum
Nov 13 at 21:41
@karakfa, nevermind, I found it. The right way seems to be the following:ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!
– ScutulatIum
Nov 13 at 21:48
2
2
xargs
is wrong there, you have to pipe stdout and stderr to awk
.– karakfa
Nov 13 at 19:09
xargs
is wrong there, you have to pipe stdout and stderr to awk
.– karakfa
Nov 13 at 19:09
@karakfa, thanks for your input. I removed
xargs
and tried this: ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output: ping: -: Name or service not known
.– ScutulatIum
Nov 13 at 21:41
@karakfa, thanks for your input. I removed
xargs
and tried this: ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output: ping: -: Name or service not known
.– ScutulatIum
Nov 13 at 21:41
@karakfa, nevermind, I found it. The right way seems to be the following:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!– ScutulatIum
Nov 13 at 21:48
@karakfa, nevermind, I found it. The right way seems to be the following:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!– ScutulatIum
Nov 13 at 21:48
add a comment |
1 Answer
1
active
oldest
votes
Thank you so much for pointing me into the right direction @karakfa. It seems that the right way is as follows:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
CORRECTION, redirect stderr to stdout, then pipe stdout to awk:
ping -qc 3 -W 5 8.8.8.8 2>&1 | awk -f presetup/testping.awk
OR:
ping -qc 3 -W 5 8.8.8.8 |& awk -f presetup/testping.awk
Thanks @tripleee!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thank you so much for pointing me into the right direction @karakfa. It seems that the right way is as follows:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
CORRECTION, redirect stderr to stdout, then pipe stdout to awk:
ping -qc 3 -W 5 8.8.8.8 2>&1 | awk -f presetup/testping.awk
OR:
ping -qc 3 -W 5 8.8.8.8 |& awk -f presetup/testping.awk
Thanks @tripleee!
add a comment |
Thank you so much for pointing me into the right direction @karakfa. It seems that the right way is as follows:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
CORRECTION, redirect stderr to stdout, then pipe stdout to awk:
ping -qc 3 -W 5 8.8.8.8 2>&1 | awk -f presetup/testping.awk
OR:
ping -qc 3 -W 5 8.8.8.8 |& awk -f presetup/testping.awk
Thanks @tripleee!
add a comment |
Thank you so much for pointing me into the right direction @karakfa. It seems that the right way is as follows:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
CORRECTION, redirect stderr to stdout, then pipe stdout to awk:
ping -qc 3 -W 5 8.8.8.8 2>&1 | awk -f presetup/testping.awk
OR:
ping -qc 3 -W 5 8.8.8.8 |& awk -f presetup/testping.awk
Thanks @tripleee!
Thank you so much for pointing me into the right direction @karakfa. It seems that the right way is as follows:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
CORRECTION, redirect stderr to stdout, then pipe stdout to awk:
ping -qc 3 -W 5 8.8.8.8 2>&1 | awk -f presetup/testping.awk
OR:
ping -qc 3 -W 5 8.8.8.8 |& awk -f presetup/testping.awk
Thanks @tripleee!
edited Nov 14 at 16:35
answered Nov 13 at 22:00
ScutulatIum
13
13
add a comment |
add a comment |
2
xargs
is wrong there, you have to pipe stdout and stderr toawk
.– karakfa
Nov 13 at 19:09
@karakfa, thanks for your input. I removed
xargs
and tried this:ping -qc 3 -W 5 8.8.8.8 2>&1 awk -f presetup/testping.awk -
without success. I had the following output:ping: -: Name or service not known
.– ScutulatIum
Nov 13 at 21:41
@karakfa, nevermind, I found it. The right way seems to be the following:
ping -qc 3 -W 5 8.8.8.8 | 2>&1 awk -f presetup/testping.awk -
Thanks for pointing me into the right direction!– ScutulatIum
Nov 13 at 21:48