Python to check status of the port in linux machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pythi1 n
    New Member
    • Dec 2011
    • 1

    Python to check status of the port in linux machine

    Hi ALL,

    I'm working on a module installation script for linux using python,
    I need a ex script to check wheather the port is free or listening before using it for installtion,
    EX: Imagine if the port 1234 is already used for some process in the liunux machine 5.6.7.8,
    This can be found using command
    $netstat -anp | grep 1234

    if u guys know how to invoke and check the same, i need to use the result of the above command in my python for further process i used os.system() command but the output is not as expected,
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Subprocess replaces os.system. See "Capturing Output" here.

    Comment

    Working...