How's the right way to pipe stdout & stderr from ping into an awk program? [duplicate]










-1
















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?










share|improve this question















marked as duplicate by tripleee, Community Nov 16 '18 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 to awk.

    – karakfa
    Nov 13 '18 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 '18 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 '18 at 21:48
















-1
















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?










share|improve this question















marked as duplicate by tripleee, Community Nov 16 '18 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 to awk.

    – karakfa
    Nov 13 '18 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 '18 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 '18 at 21:48














-1












-1








-1









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?










share|improve this question

















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 21:58







ScutulatIum

















asked Nov 13 '18 at 18:09









ScutulatIumScutulatIum

13




13




marked as duplicate by tripleee, Community Nov 16 '18 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 '18 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 to awk.

    – karakfa
    Nov 13 '18 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 '18 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 '18 at 21:48













  • 2





    xargs is wrong there, you have to pipe stdout and stderr to awk.

    – karakfa
    Nov 13 '18 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 '18 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 '18 at 21:48








2




2





xargs is wrong there, you have to pipe stdout and stderr to awk.

– karakfa
Nov 13 '18 at 19:09





xargs is wrong there, you have to pipe stdout and stderr to awk.

– karakfa
Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 21:48













1 Answer
1






active

oldest

votes


















-1














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!






share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    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!






    share|improve this answer





























      -1














      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!






      share|improve this answer



























        -1












        -1








        -1







        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!






        share|improve this answer















        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!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '18 at 16:35

























        answered Nov 13 '18 at 22:00









        ScutulatIumScutulatIum

        13




        13















            Popular posts from this blog

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Syphilis

            Darth Vader #20