lbenitez000 / trparse

Parses the output of a traceroute execution into an AST
MIT License
13 stars 14 forks source link

Documentation input example #14

Open emiliogq opened 5 years ago

emiliogq commented 5 years ago

Hi,

I am trying to do the following command in Python: traceroute -A google.es | cat > test.txt

So, what I've done is the following:

tracerouteProcess = subprocess.Popen(["traceroute","-A","google.es"]. stdout=subprocess.PIPE) f = open("test.txt", "w")

Sending the output from traceroute to a file using cat because the OS of host (SELinux) where the script will be executed does not allow directly redirecting the traceroute output to a file.

catProcess = subprocess.Popen(["cat"], stdin=tracerouteProcess.stdout, stdout=f) catProcess.communicate() string = f.read() traceroute = trparse.loads(string)

And it raises the following error:

dest_name = match_dest.group(1) AttributeError: 'NoneType' object has no attribute 'group'

I will appreciate some kind of example to see what I am doing wrong.

Thanks in advance

rarylson commented 4 years ago

Hello @emiliogq, your problem may be related to issue #10 .

In your example, you are using trparse to parse the stdout of traceroute. But trparse expects both stderr + stdout (because the traceroute header is printed to stderr).

If this is what is causing your issue, please +1 the issue #10.

Note: I'm planning to create a PR to the project owner addressing this problem.