Sharat Chandra
Sharat Chandra

Reputation: 4544

Netstat -i redirection problem

When I run this command netstat -t 1 -i 2>&1 > $NETStat_OUT_FILE & inside a script , the output of netstat does not get redirected to the file.. Could any one find a solution for this ?

Upvotes: 1

Views: 989

Answers (2)

ceving
ceving

Reputation: 23866

In order to solve the timing problem you can use wait:

netstat ... &
p=$!
do something else ...
wait $p

Upvotes: 0

Dennis Williamson
Dennis Williamson

Reputation: 360143

You need to redirect stdout first, then stderr.

netstat -t 1 -i > $NETStat_OUT_FILE 2>&1 &

Upvotes: 1

Related Questions