Re: tcpdump + IFS = no sense?



On 29 Aug 2006 08:49:46 -0700, tony.andreoli@xxxxxxxxx wrote:
Ok, perhaps one of the experts here can help. I'm just trying to write
a small script that will start a tcpdump. The dump will be started
with a variable for tcpdump's parameters. This works fine:

cmd="-i eth0"
tcpdump $cmd

BUT, if I then add an IFS command before it (to eventually allow me to
read the parameters from a config file) it doesn't work. This fails:

IFS="
"
cmd="-i eth0"
tcpdump $cmd

with a "tcpdump: ioctl: No such device"
I've tried it with Redhat EL3 and FC5 with the same results. Can
someone explain what the heck's going on?

bash can't parse the command string properly because you changed the
field separator. What are you setting IFS to?

$IFS
internal field separator
This variable determines how Bash recognizes fields, or word
boundaries when it interprets character strings.
$IFS defaults to whitespace (space, tab, and newline), but may be
changed, for example, to parse a comma-separated data file. Note that
$* uses the first character held in $IFS. See Example 5-1.

--
Dale Dellutri <ddelQQQlutr@xxxxxxxxxxxx> (lose the Q's)
.



Relevant Pages

  • Re: tcpdump + IFS = no sense?
    ... it's just that tcpdump is choking. ... What are you setting IFS to? ... internal field separator ... boundaries when it interprets character strings. ...
    (comp.os.linux.networking)
  • Re: em0, VLAN and bpf(?) trouble w/RELENG_5
    ... As soon as I stop the tcpdump, ... cmd 0x03, sap aa ui/C len=39 ...
    (freebsd-current)
  • tcpdump + IFS = no sense?
    ... a small script that will start a tcpdump. ... The dump will be started ... tcpdump $cmd ...
    (comp.os.linux.networking)