On Oct 2, 2012, at 11:10 AM, esolve esolve <esolvepolito@xxxxxxxxx> wrote:
> I have a script where I want to run tcpdump and then immediately run another command
> however, tcpdump will cause the shell pause/hang
> so the following command lines will have no chance to run
>
> even if I use &, it doesn't help
> like
>
> [root@ket capture]# tcpdump -i eth0 -w temp &
> [2] 32076
> [root@ket capture]# tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
>
>
> it always switches to foreground even with &
Why do you think it's in the foreground? The fact that it prints to the (pseudo-)terminal doesn't mean that - background jobs can write to the terminal (unless you do "stty tostop", which means they'll stop if they try to write to the terminal, but that's not what you want), they just can't *read from* the terminal without stopping.
If you don't want the "listening on..." message printed, you'd have to redirect the standard error of tcpdump to /dev/null (which means you won't see any error messages it prints) or to a file (in which case that message *and* any error messages will show up in the file).