0

i am trying to execute the tshark command to find packets of a particular IP address in bash command as follows::

while read client
do  
echo "Client Adrees:" $client1
cmd="tshark -R \"(ip.src == 10.129.5.192)\" -r 12clients.pcap"  
echo $cmd

done < input

while executing script the error is as follows::

Client Adrees: 10.129.26.154
tshark -R "(ip.src == 10.129.5.192)" -r 12clients.pcap
tshark: Read filters were specified both with "-R" and with additional command-line arguments

thanks in advance... :D

1

1 Answer 1

2

Use an array variable instead to store and execute your command - using a single string with literal double quotes won't be interpreted correctly:

# Store command tokens in an array.
# Note that each word or quoted phrase will form a separate array element.
cmd=( tshark -R "(ip.src == 10.129.5.192)" -r 12clients.pcap )

# Invoke command as the expanded array.
# Double-quoting it prevents shell expansions of the elements.
"${cmd[@]}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.