I am using such a command to write oracle sqlplus query result to text file:
sqlplus -S xxx/xxx@xxxxxxx @\tmp\2.sql>\tmp\123.txt
Is it possible to script that:
If command succesfull write in \tmp\log.txt:
timestamp and "succeded"
and create 123.txt with results
else
If error occured (ORA error, or OS error), write in \tmp\log.txt file
timestamp "failed" error code
(but don't write error in file 123.txt - dont create file 123.txt)
Seems like you are asking for too much to write in a single command! I do not think it is possible to execute However, we can certainly write a shell script that satisfies your requirement, albeit with some modifications.