Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ?

share|improve this question
    
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 '11 at 1:45
add comment

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.

share|improve this answer
    
Nothing is wrong with the declaration.. The problem is arising for me only if i specify the "-i" flag .. –  kashyapa Apr 27 '10 at 19:54
    
What's the whole script or at least the part that sets $NETStat_OUT_FILE? –  Marnix A. van Ammers Apr 27 '10 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 '10 at 20:33
add comment

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.

share|improve this answer
    
`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 '10 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 '10 at 20:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.