Windows Handling Piped Comands Error Redirection

Posted by jpmartins on Server Fault See other posts from Server Fault or by jpmartins
Published on 2010-04-27T11:21:07Z Indexed on 2010/04/27 11:23 UTC
Read the original article Hit count: 422

Filed under:
|
|

Warning: I am no expert on building scripts, and sorry for lousy English.

In an case of generating a CSV from a database query I'm using the following commands.

... CALL java.exe -classpath ... com.xigole.util.sql.Jisql -user dmfodbc -pf pwd.file -driver com.sybase.jdbc3.jdbc.SybDriver -cstring %constr% -c ; -input 42.sql -formatter csv -delimiter ; 2>>%LOGFILE% | CALL grep -v -e "SELECT right" -e "executing: " -e " rows affect" > %FicheiroR% 2>>%LOGFILE% ...

I'm using windows implementation of grep.

The 2>>%LOGFILE% in both java and grep command is causing an error message indicating the file is being use by another process.

The Ugly workaround i have came up with is to put grep error redirect to a temporary %LOGFILE%.aux

java ... | grep ... 2>>%LOGFILE%.aux type %LOGFILE%.aux >> % %LOGFILE% del %LOGFILE%.aux

What is a better solution?

© Server Fault or respective owner

Related posts about Windows

Related posts about scripting