Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6028643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:46:13+00:00 2026-05-23T04:46:13+00:00

Expected Behavior Under normal circumstances, I can issue tshark -E separator=’@’ under linux See

  • 0

Expected Behavior

Under normal circumstances, I can issue tshark -E separator='@' under linuxSee Note A and force it to display fields separated by @, as shown below…

[mpenning@hotcoffee ~]$ tshark -r scp_test.pcap -e frame.number -e ip.src_host -e tcp.srcport -E separator='@' -T fields tcp | less
1@192.168.12.236@33088
2@192.168.12.238@22
3@192.168.12.236@33088
...

Unexpected Behavior

Likewise, I thought I would run the same command through subprocess.Popen(), columnify, and colorize based on some analysis… all my analysis depends on the output being separated by @ when I run the script… however, my script is not using @… instead, it uses a single-quote; I am not sure I understand why this is happening.

Script

import subprocess
import sys

filename = sys.argv[1].strip()
fields = ['frame_num', 'IP Src', 'TCP Src']
sep = '@'
cmd = r"""tshark -r %s -e frame.number -e ip.src_host -e tcp.srcport -E separator='%s' -T fields tcp""" % (filename, sep)

subcmd = cmd.split(' ')
lines = subprocess.Popen(subcmd, stdout = subprocess.PIPE)
for line in lines.communicate()[0].split('\n'):
    print line

Results

[mpenning@hotcoffee ~]$ python analyze.py scp_test.pcap | less
1'192.168.12.236'33088
2'192.168.12.238'22
3'192.168.12.236'33088
4'192.168.12.238'22
5'192.168.12.236'33088
6'192.168.12.236'33088
7'192.168.12.238'22
8'192.168.12.236'33088

It seemingly does not matter whether I assign sep using any of the following…

  • sep = '@'
  • sep = '\@'
  • sep = re.escape('@') # Desperation attempt ;-)

Question

Can someone explain:

  1. Why my output is not separated with @ in the script above.
  2. How I can fix the script using subprocessSee Note B?

End-Notes

Note A. System information:

[mpenning@hotcoffee ~]$ python -V
Python 2.6.6
[mpenning@hotcoffee ~]$ uname -a
Linux hotcoffee 2.6.32-5-amd64 #1 SMP Mon Mar 7 21:35:22 UTC 2011 x86_64 GNU/Linux
[mpenning@hotcoffee ~]$

Note B. Answers using os.system() or os.popen() are not what I’m looking for

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:46:14+00:00Added an answer on May 23, 2026 at 4:46 am

    tshark is taking the ' from '%s'. don’t use the single-quotes:

    cmd = r"tshark -r %s -e frame.number -e ip.src_host -e tcp.srcport -E separator=%s -T fields tcp" % (filename, sep)
    

    when you ran it from the command line, Bash stripped the single-quotes off and tshark didn’t see them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can
I'm maintaining a web page and need to fix a very weird behavior under
I'm getting unexpected behavior in my Android 1.5 application under the Windows emulator and
You can scroll an UIPickerView both by swiping and by tapping items under or
Expected output & output I get in debug mode, and release mode under VS2010,
I'm not really sure why the following console application doesn't produce the expected behavior
I expected the two span tags in the following sample to display next to
The expected probability of randomly selecting an element from a set of n elements
I expected A::~A() to be called in this program, but it isn't: #include <iostream>
I get the following compilation error: error: expected `;' before 'it' Here's my code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.