This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

capture filter problem when tshark is started within a bash-script

0

Hi,

I have a little problem when starting tshark out of a bash-script. Here a short part from the script:

BIN="/usr/bin/tshark"
OPTS=" -f \"port 5026 and (host 10.65.27.138 or host 10.65.27.137 or host 10.65.27.139)\" -a duration:10 -i eth1 -n -q -w /data/traces/files/test2.pcap"
echo $BIN $OPTS
$BIN $OPTS

Now I'm receiving following output:

/usr/bin/tshark -f "port 5026 and (host 10.65.27.138 or host 10.65.27.137 or host 10.65.27.139)" -a duration:10 -i eth1 -n -q -w /data/traces/files/tma_ffm_1_smpp_hsbu1a1/test2.pcap
tshark: Capture filters were specified both with "-f" and with additional command-line arguments

When starting tshark directly from the bash with the output of "echo $BIN $OPTS" everything is working fine. I've tried several versions of declaring $OPTS like

  • OPTS=" -f "filters" "
  • OPTS=' -f "filters" '
  • OPTS=" -f 'filter' "

but all with the same result as mentioned above. Tested with tshark 0.99.6, 1.0.5 and 1.2.8

Hope anyone can help me again ;)

BR Sascha

asked 20 Oct '10, 03:21

Sascha's gravatar image

Sascha
6223
accept rate: 100%


One Answer:

0

Hi again,

dont think it's a good solution, but I found an usable workaround:

OPTS=" -b duration:900 -i eth2 -n -q -w /data/traces/files/tma_ffm_1_smpp_hsbu1b1/tma_ffm_1_smpp_hsbu1b1.pcap port 5026 and (host 10.65.27.138 or host 10.65.27.137 or host 10.65.27.139)"

As all the last arguments are interpreted as capture filter, this is working.

If anybody knows a better way, please let me know.

BR Sascha

answered 20 Oct '10, 06:25

Sascha's gravatar image

Sascha
6223
accept rate: 100%