|
Answer» Hi,
I am trying to run the batch files in ORDER to do the migration of data from 1 database to another. But, while running it , i want the output in a text file so ,i did following things in a command prompt
D:\Migration\migrate.bat >> error.txt I am getting all the things happening in a text file except the errors that i need to know , as in command prompt the error gets removed immediately and new screen comes, so not able to notice the error.
Kindly let me know .
Regards, Pankaj
try to use stderr
1 - stdout
Code: [Select]dir qwerty 1>file.txt
Code: [Select] Volume in drive H is Win 7 Volume Serial Number is C816-431A
Directory of H:\ 2 - stderr
Code: [Select]dir qwerty 2>file.txt
Code: [Select]File Not Found
so try
Code: [Select]D:\Migration\migrate.bat 2>>error.txti tried, but in this case , i am getting everything on command prompt and i want the error to be generated in a text file.Let me explain you the case in DETAIL :
I have a table "A" in oracle database I have migrated all the data of table "A" from oracle DB to Postgres DB through an ETL TOOL with only insert OPTION given in that table .
There is 1 primary key in table "A" .
Now, if 2nd time i will run the same thing i will get an error as " Duplicate Key" like that ...
Now, i want all the error to come in text file , but it is not giving me the same.
Kindly let me know,if u got dat
Regards, Pankaj 2nd time i want to run that through a "bat" file in a command prompt.
I am getting the error message in command prompt like which goes on increasing.
I , therefore want all the error message and output in text file only , thats why i did
D:\Migration\migrate.bat >> error.txt
but , it is not giving me the error message.
regards, pankaj http://www.robvanderwoude.com/battech_redirection.php
This has already been covered with a slightly different explanation
Some "best practices" when using redirection in batch files:
•Use >filename.txt 2>&1 to merge Standard Output and Standard Error and redirect them together to a single file.
Make sure you place the redirection "commands" in this order.
•Use >logfile.txt 2>errorlog.txt to redirect success and error messages to separate log files.
•Use >CON to send text to the screen, no matter what, even if the batch file's output is redirected.
This could be useful when prompting for input even if the batch file's output is being redirected to a file. •Use 1>&2 to send text to Standard Error.
This can be useful for error messages.
•It's ok to use spaces in redirection commands. Note however, that a space between an ECHO command and a > will be redirected too.
DIR>filename.txt and DIR > filename.txt are identical, ECHO Hello world>filename.txt and ECHO Hello world > filename.txt are not, even though they are both valid.
It is not ok to use spaces in >> or 2> or 2>&1 or 1>&2 (before or after is ok).
. . . Thanks a TON for your help , bro
|