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 ?
-
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.– bbaja42Jun 12, 2011 at 1:45
2 Answers
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.
-
Nothing is wrong with the declaration.. The problem is arising for me only if i specify the "-i" flag ..– kashyapaApr 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– kashyapaApr 27, 2010 at 20:33
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.
-
`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 &– kashyapaApr 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– kashyapaApr 27, 2010 at 20:28