Sushrut Naik
Sushrut Naik

Reputation: 17

How do I not read '\t' as a tab in python strings

os.system("'C:\Program Files\Wireshark\tshark.exe' -r B2.pcap -T fields -e frame.number -e frame.time -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport -e ip.proto -e ip.flags.syn -e ip.flags.nf -e ip.flags.df -e frame.len -E header=y -E separator=, > traffic.csv")

I'm trying to run the above command in python but its reading the \t in the \tshark.exe part as a tab character. How do I solve this?

Upvotes: 0

Views: 1047

Answers (3)

ev-br
ev-br

Reputation: 26080

Raw strings start with the r symbol: r"string with \t \n"

Upvotes: 2

Minh-Long Luu
Minh-Long Luu

Reputation: 2741

Probably because this one is wrapped in string?

"'C:\Program Files\Wireshark\tshark.exe'..."

try using raw string.

Upvotes: 0

aidan0626
aidan0626

Reputation: 307

try

os.system("'C:\Program Files\Wireshark\\tshark.exe' -r B2.pcap -T fields -e frame.number -e frame.time -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport -e ip.proto -e ip.flags.syn -e ip.flags.nf -e ip.flags.df -e frame.len -E header=y -E separator=, > traffic.csv")

Backslashes are used to "escape" characters and if you want to print out a backslash, you have to escape it with another backslash

Upvotes: 1

Related Questions