This script should do the following: Execute the command " netstat /a " manually in a terminal and acquaint youself with the content of the output Use the os module to execute " netstat /a " while...

This script should do the following:


  1. Execute the command "netstat /a" manually in a terminal and acquaint youself with the content of the output

  2. Use theosmodule to execute "netstat /a" while redirecting to a file calledc:\temp\mypythonfiles\currports.txt

  3. Open the newly created file for reading

  4. Create a loop to read each line from the file; within the loop:

    • Use a
      split()
      to break apart the current line of text to obtain a list of substrings; if there are no substrings (empty list) then continue

    • Check to see if a port is listening; the last element of the list should determine if a port is listening or not; use the
      lower()
      method to make the last element lowercase then use an
      if
      statement to check to see if its value is "listening"

    • If the port is listening, then print the local address (should be the second substring in the list)



  5. Close the file

Apr 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here