0

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 ?

1
  • As response to your comments, try opening output with tail -f output.file , that way you will see it as soon as it's written.
    – bbaja42
    Jun 12, 2011 at 1:45

2 Answers 2

0

What's the whole line? Chances are the problem is in the declaration of the $NETStat_OUT_FILE variable, because the rest seems to work normally.

3
  • Nothing is wrong with the declaration.. The problem is arising for me only if i specify the "-i" flag ..
    – kashyapa
    Apr 27, 2010 at 19:54
  • What's the whole script or at least the part that sets $NETStat_OUT_FILE? Apr 27, 2010 at 19:55
  • sorry.. there is no problem as such..but when i try to read the output file immediately after execution it puts out a blank file.. the redirection program takes time to write the output onto the output file..i'm able to view the output if i open it after sometime
    – kashyapa
    Apr 27, 2010 at 20:33
0

Does the file get created at all? Try changing "$NETStat_OUT_FILE" to "${NETStat_OUT_FILE:?}" to catch the possibility of a typo. It's possible that the output is being buffered, so that you won't see anything in the file until after some block of text (probably 512 bytes) has been buffered and flushed.

2
  • `PROJ_DIR="/cac/u01/sharatds/ScriptsNETStat_OUT_FILE="$PROJ_DATA_DIR PROJ_DATA_DIR="$PROJ_DIR/data" NETStat_OUT_FILE="$PROJ_DATA_DIR/NETstat.outputfile.lap01.$1.txt"; netstat -t 1 2>&1 > $NETStat_OUT_FILE &
    – kashyapa
    Apr 27, 2010 at 20:04
  • sorry.. there is no problem as such..but when i try to read the output file immediately after execution it puts out a blank file.. the redirection program takes time to write the output onto the output file..i'm able to view the output if i open it after sometime
    – kashyapa
    Apr 27, 2010 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .