script to verify running services on specific ports

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I got a task to do.



I have to search whether, are there running services on below ports.

ports 53 & 55

If not I have to send alerts.

Please correct my logic and syntax in below code for one port



ntstat=`netstat -tulpn | grep :53 | grep LISTEN | awk 'print $4'`
port="*:53"

#Just to echo for testing
echo $ntstat
echo $port

if [[ "$ntstat" == "$port" ]];
then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi



Output :



127.0.1.1:53
*:53
Port is not listing


I am struggling to match strings (127.0.1.1:53 to *:53)










share|improve this question























  • @Kusalananda please look into this
    – Prabash
    Oct 10 '17 at 17:28










  • You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
    – Kusalananda
    Oct 10 '17 at 21:26











  • Thanks . No worries
    – Prabash
    Oct 11 '17 at 0:37















up vote
2
down vote

favorite












I got a task to do.



I have to search whether, are there running services on below ports.

ports 53 & 55

If not I have to send alerts.

Please correct my logic and syntax in below code for one port



ntstat=`netstat -tulpn | grep :53 | grep LISTEN | awk 'print $4'`
port="*:53"

#Just to echo for testing
echo $ntstat
echo $port

if [[ "$ntstat" == "$port" ]];
then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi



Output :



127.0.1.1:53
*:53
Port is not listing


I am struggling to match strings (127.0.1.1:53 to *:53)










share|improve this question























  • @Kusalananda please look into this
    – Prabash
    Oct 10 '17 at 17:28










  • You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
    – Kusalananda
    Oct 10 '17 at 21:26











  • Thanks . No worries
    – Prabash
    Oct 11 '17 at 0:37













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I got a task to do.



I have to search whether, are there running services on below ports.

ports 53 & 55

If not I have to send alerts.

Please correct my logic and syntax in below code for one port



ntstat=`netstat -tulpn | grep :53 | grep LISTEN | awk 'print $4'`
port="*:53"

#Just to echo for testing
echo $ntstat
echo $port

if [[ "$ntstat" == "$port" ]];
then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi



Output :



127.0.1.1:53
*:53
Port is not listing


I am struggling to match strings (127.0.1.1:53 to *:53)










share|improve this question















I got a task to do.



I have to search whether, are there running services on below ports.

ports 53 & 55

If not I have to send alerts.

Please correct my logic and syntax in below code for one port



ntstat=`netstat -tulpn | grep :53 | grep LISTEN | awk 'print $4'`
port="*:53"

#Just to echo for testing
echo $ntstat
echo $port

if [[ "$ntstat" == "$port" ]];
then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi



Output :



127.0.1.1:53
*:53
Port is not listing


I am struggling to match strings (127.0.1.1:53 to *:53)







shell-script regular-expression string netstat






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 10 '17 at 17:25









Thomas

3,62141124




3,62141124










asked Oct 10 '17 at 17:15









Prabash

226




226











  • @Kusalananda please look into this
    – Prabash
    Oct 10 '17 at 17:28










  • You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
    – Kusalananda
    Oct 10 '17 at 21:26











  • Thanks . No worries
    – Prabash
    Oct 11 '17 at 0:37

















  • @Kusalananda please look into this
    – Prabash
    Oct 10 '17 at 17:28










  • You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
    – Kusalananda
    Oct 10 '17 at 21:26











  • Thanks . No worries
    – Prabash
    Oct 11 '17 at 0:37
















@Kusalananda please look into this
– Prabash
Oct 10 '17 at 17:28




@Kusalananda please look into this
– Prabash
Oct 10 '17 at 17:28












You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
– Kusalananda
Oct 10 '17 at 21:26





You've got some answers from people on Linux systems. I'm not on Linux and my netstat is different. Could you not also check the daemons that are supposed to listen on those ports? Some systemctl command or other to make sure they are running? (again, I'm not on Linux)
– Kusalananda
Oct 10 '17 at 21:26













Thanks . No worries
– Prabash
Oct 11 '17 at 0:37





Thanks . No worries
– Prabash
Oct 11 '17 at 0:37











3 Answers
3






active

oldest

votes

















up vote
0
down vote



accepted










You can also do a text-processing to your current output to match the port. Just add sed -e 's/.*:/:/g'



#!/bin/bash
ntstat=`netstat -tulpn | grep ":53 " | grep LISTEN | awk 'print $4' | sed -e 's/.*:/:/g'`
port=":53 "

#Just to echo for testing
echo $ntstat
echo $port

if [[ "$ntstat" == "$port" ]]
then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi


Please note that I added a space right after the port number in order to avoid other ports containing 53



Since this are bash operators, you must want to put the shebang #!/bin/bash at the very top of your script so when you execute your script as ./portlisten.sh, it will take the interpreter as /bin/bash, would be the same if you execute your script as $ bash portlisten.sh






share|improve this answer






















  • Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
    – Prabash
    Oct 11 '17 at 0:43










  • I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
    – Prabash
    Oct 11 '17 at 3:04











  • @Prabash I edited the answer, give a try
    – tachomi
    Oct 11 '17 at 13:43










  • so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
    – Prabash
    Oct 12 '17 at 5:59











  • I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
    – Prabash
    Oct 12 '17 at 7:34


















up vote
1
down vote













To check if there are running services on ports 53(or 55) I would suggest the following optimized solution:



port=":53"
if netstat -tulpn | grep --line-buffered -q "$port .*LISTEN"; then
echo " X Service at port number $port"
else
echo " Port is not listing "
fi





share|improve this answer



























    up vote
    0
    down vote













    Don't use netstat since this is a deprecated command, use ss instead.



    In your case you could use something like:



    ss -H -o state listening '( sport = :53 or sport = :55 )' 





    share|improve this answer
















    • 1




      Who deprecated netstat? How can a non-standard utility be deprecated?
      – Kusalananda
      Oct 11 '17 at 6:07










    • @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
      – Valentin B
      Oct 11 '17 at 9:17










    • @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
      – Kusalananda
      Oct 11 '17 at 9:19










    • @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
      – Valentin B
      Oct 11 '17 at 9:22










    • @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
      – Kusalananda
      Oct 11 '17 at 9:24










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f397271%2fscript-to-verify-running-services-on-specific-ports%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    You can also do a text-processing to your current output to match the port. Just add sed -e 's/.*:/:/g'



    #!/bin/bash
    ntstat=`netstat -tulpn | grep ":53 " | grep LISTEN | awk 'print $4' | sed -e 's/.*:/:/g'`
    port=":53 "

    #Just to echo for testing
    echo $ntstat
    echo $port

    if [[ "$ntstat" == "$port" ]]
    then
    echo " X Service at port number $port"
    else
    echo " Port is not listing "
    fi


    Please note that I added a space right after the port number in order to avoid other ports containing 53



    Since this are bash operators, you must want to put the shebang #!/bin/bash at the very top of your script so when you execute your script as ./portlisten.sh, it will take the interpreter as /bin/bash, would be the same if you execute your script as $ bash portlisten.sh






    share|improve this answer






















    • Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
      – Prabash
      Oct 11 '17 at 0:43










    • I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
      – Prabash
      Oct 11 '17 at 3:04











    • @Prabash I edited the answer, give a try
      – tachomi
      Oct 11 '17 at 13:43










    • so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
      – Prabash
      Oct 12 '17 at 5:59











    • I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
      – Prabash
      Oct 12 '17 at 7:34















    up vote
    0
    down vote



    accepted










    You can also do a text-processing to your current output to match the port. Just add sed -e 's/.*:/:/g'



    #!/bin/bash
    ntstat=`netstat -tulpn | grep ":53 " | grep LISTEN | awk 'print $4' | sed -e 's/.*:/:/g'`
    port=":53 "

    #Just to echo for testing
    echo $ntstat
    echo $port

    if [[ "$ntstat" == "$port" ]]
    then
    echo " X Service at port number $port"
    else
    echo " Port is not listing "
    fi


    Please note that I added a space right after the port number in order to avoid other ports containing 53



    Since this are bash operators, you must want to put the shebang #!/bin/bash at the very top of your script so when you execute your script as ./portlisten.sh, it will take the interpreter as /bin/bash, would be the same if you execute your script as $ bash portlisten.sh






    share|improve this answer






















    • Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
      – Prabash
      Oct 11 '17 at 0:43










    • I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
      – Prabash
      Oct 11 '17 at 3:04











    • @Prabash I edited the answer, give a try
      – tachomi
      Oct 11 '17 at 13:43










    • so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
      – Prabash
      Oct 12 '17 at 5:59











    • I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
      – Prabash
      Oct 12 '17 at 7:34













    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    You can also do a text-processing to your current output to match the port. Just add sed -e 's/.*:/:/g'



    #!/bin/bash
    ntstat=`netstat -tulpn | grep ":53 " | grep LISTEN | awk 'print $4' | sed -e 's/.*:/:/g'`
    port=":53 "

    #Just to echo for testing
    echo $ntstat
    echo $port

    if [[ "$ntstat" == "$port" ]]
    then
    echo " X Service at port number $port"
    else
    echo " Port is not listing "
    fi


    Please note that I added a space right after the port number in order to avoid other ports containing 53



    Since this are bash operators, you must want to put the shebang #!/bin/bash at the very top of your script so when you execute your script as ./portlisten.sh, it will take the interpreter as /bin/bash, would be the same if you execute your script as $ bash portlisten.sh






    share|improve this answer














    You can also do a text-processing to your current output to match the port. Just add sed -e 's/.*:/:/g'



    #!/bin/bash
    ntstat=`netstat -tulpn | grep ":53 " | grep LISTEN | awk 'print $4' | sed -e 's/.*:/:/g'`
    port=":53 "

    #Just to echo for testing
    echo $ntstat
    echo $port

    if [[ "$ntstat" == "$port" ]]
    then
    echo " X Service at port number $port"
    else
    echo " Port is not listing "
    fi


    Please note that I added a space right after the port number in order to avoid other ports containing 53



    Since this are bash operators, you must want to put the shebang #!/bin/bash at the very top of your script so when you execute your script as ./portlisten.sh, it will take the interpreter as /bin/bash, would be the same if you execute your script as $ bash portlisten.sh







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 11 '17 at 13:43

























    answered Oct 10 '17 at 18:29









    tachomi

    3,47431134




    3,47431134











    • Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
      – Prabash
      Oct 11 '17 at 0:43










    • I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
      – Prabash
      Oct 11 '17 at 3:04











    • @Prabash I edited the answer, give a try
      – tachomi
      Oct 11 '17 at 13:43










    • so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
      – Prabash
      Oct 12 '17 at 5:59











    • I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
      – Prabash
      Oct 12 '17 at 7:34

















    • Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
      – Prabash
      Oct 11 '17 at 0:43










    • I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
      – Prabash
      Oct 11 '17 at 3:04











    • @Prabash I edited the answer, give a try
      – tachomi
      Oct 11 '17 at 13:43










    • so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
      – Prabash
      Oct 12 '17 at 5:59











    • I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
      – Prabash
      Oct 12 '17 at 7:34
















    Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
    – Prabash
    Oct 11 '17 at 0:43




    Thanks lot for your solution . Can please explan how does sed -e 's/.*:/:/g' command works with my output 127.0.1.1:53.since i am very new to sed commands .
    – Prabash
    Oct 11 '17 at 0:43












    I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
    – Prabash
    Oct 11 '17 at 3:04





    I have implemented your code. but still i am getting this out put - :53 :53 portlisten.sh: 10: portlisten.sh: [[: not found Port is not listing
    – Prabash
    Oct 11 '17 at 3:04













    @Prabash I edited the answer, give a try
    – tachomi
    Oct 11 '17 at 13:43




    @Prabash I edited the answer, give a try
    – tachomi
    Oct 11 '17 at 13:43












    so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
    – Prabash
    Oct 12 '17 at 5:59





    so i added your new code and execute as ./portlisten.sh please find output as below :53 :53 Port is not listing still it says "port is not listing" , I think we have problem with string matching
    – Prabash
    Oct 12 '17 at 5:59













    I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
    – Prabash
    Oct 12 '17 at 7:34





    I am able to below get out put :53 :53 X Service at port number :53 #I have removed " " in variables comparison ..... if [[ $ntstat == $port ]] . Once again thank for your support.
    – Prabash
    Oct 12 '17 at 7:34













    up vote
    1
    down vote













    To check if there are running services on ports 53(or 55) I would suggest the following optimized solution:



    port=":53"
    if netstat -tulpn | grep --line-buffered -q "$port .*LISTEN"; then
    echo " X Service at port number $port"
    else
    echo " Port is not listing "
    fi





    share|improve this answer
























      up vote
      1
      down vote













      To check if there are running services on ports 53(or 55) I would suggest the following optimized solution:



      port=":53"
      if netstat -tulpn | grep --line-buffered -q "$port .*LISTEN"; then
      echo " X Service at port number $port"
      else
      echo " Port is not listing "
      fi





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        To check if there are running services on ports 53(or 55) I would suggest the following optimized solution:



        port=":53"
        if netstat -tulpn | grep --line-buffered -q "$port .*LISTEN"; then
        echo " X Service at port number $port"
        else
        echo " Port is not listing "
        fi





        share|improve this answer












        To check if there are running services on ports 53(or 55) I would suggest the following optimized solution:



        port=":53"
        if netstat -tulpn | grep --line-buffered -q "$port .*LISTEN"; then
        echo " X Service at port number $port"
        else
        echo " Port is not listing "
        fi






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 10 '17 at 17:42









        RomanPerekhrest

        22.5k12145




        22.5k12145




















            up vote
            0
            down vote













            Don't use netstat since this is a deprecated command, use ss instead.



            In your case you could use something like:



            ss -H -o state listening '( sport = :53 or sport = :55 )' 





            share|improve this answer
















            • 1




              Who deprecated netstat? How can a non-standard utility be deprecated?
              – Kusalananda
              Oct 11 '17 at 6:07










            • @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
              – Valentin B
              Oct 11 '17 at 9:17










            • @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
              – Kusalananda
              Oct 11 '17 at 9:19










            • @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
              – Valentin B
              Oct 11 '17 at 9:22










            • @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
              – Kusalananda
              Oct 11 '17 at 9:24














            up vote
            0
            down vote













            Don't use netstat since this is a deprecated command, use ss instead.



            In your case you could use something like:



            ss -H -o state listening '( sport = :53 or sport = :55 )' 





            share|improve this answer
















            • 1




              Who deprecated netstat? How can a non-standard utility be deprecated?
              – Kusalananda
              Oct 11 '17 at 6:07










            • @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
              – Valentin B
              Oct 11 '17 at 9:17










            • @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
              – Kusalananda
              Oct 11 '17 at 9:19










            • @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
              – Valentin B
              Oct 11 '17 at 9:22










            • @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
              – Kusalananda
              Oct 11 '17 at 9:24












            up vote
            0
            down vote










            up vote
            0
            down vote









            Don't use netstat since this is a deprecated command, use ss instead.



            In your case you could use something like:



            ss -H -o state listening '( sport = :53 or sport = :55 )' 





            share|improve this answer












            Don't use netstat since this is a deprecated command, use ss instead.



            In your case you could use something like:



            ss -H -o state listening '( sport = :53 or sport = :55 )' 






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 10 '17 at 21:13









            Valentin B

            5,51611527




            5,51611527







            • 1




              Who deprecated netstat? How can a non-standard utility be deprecated?
              – Kusalananda
              Oct 11 '17 at 6:07










            • @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
              – Valentin B
              Oct 11 '17 at 9:17










            • @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
              – Kusalananda
              Oct 11 '17 at 9:19










            • @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
              – Valentin B
              Oct 11 '17 at 9:22










            • @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
              – Kusalananda
              Oct 11 '17 at 9:24












            • 1




              Who deprecated netstat? How can a non-standard utility be deprecated?
              – Kusalananda
              Oct 11 '17 at 6:07










            • @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
              – Valentin B
              Oct 11 '17 at 9:17










            • @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
              – Kusalananda
              Oct 11 '17 at 9:19










            • @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
              – Valentin B
              Oct 11 '17 at 9:22










            • @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
              – Kusalananda
              Oct 11 '17 at 9:24







            1




            1




            Who deprecated netstat? How can a non-standard utility be deprecated?
            – Kusalananda
            Oct 11 '17 at 6:07




            Who deprecated netstat? How can a non-standard utility be deprecated?
            – Kusalananda
            Oct 11 '17 at 6:07












            @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
            – Valentin B
            Oct 11 '17 at 9:17




            @Kusalananda the netstat command is part of the net-tools bundle which hasn't been maintained since 2011. To me this is pretty much outdated and shouldn't be used in modern operating systems. Have a loop at the man netstat manpage. Once again, netstat is replaced by ss (Socket Statistics) , has a more sophisticated option set and is the future.
            – Valentin B
            Oct 11 '17 at 9:17












            @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
            – Kusalananda
            Oct 11 '17 at 9:19




            @val0x00ff Ah, the Linux netstat may well be old, but netstat, albeit another implementation of it, is also installed by default on BSDs. This is obviously not "deprecated" but actively maintained.
            – Kusalananda
            Oct 11 '17 at 9:19












            @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
            – Valentin B
            Oct 11 '17 at 9:22




            @Kusalananda BSD implementations use sockstat in that regard. Also as far as my research concerns, The man page of netstat tells us the following: NOTES This program is mostly obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for net‐ stat -i is ip -s link. Replacement for netstat -g is ip maddr.
            – Valentin B
            Oct 11 '17 at 9:22












            @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
            – Kusalananda
            Oct 11 '17 at 9:24




            @val0x00ff I'm ok with saying that the net-tools netstat may be deprecated, but the BSD version certainly is not: man.openbsd.org/netstat
            – Kusalananda
            Oct 11 '17 at 9:24

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397271%2fscript-to-verify-running-services-on-specific-ports%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)