gdal_warp and similar give a nice progress summary when run and I want this output to show in the osgeo shell and also pipe to a text file. The issue is when I add the pipe the output doesn't show on the screen. How can I do both?

gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif > %2\%3\%3_translate_log.txt

puts the output to a text file but then doesn't show the progress on screen.

I tried

Echo gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif > %2\%3\%3_translate_log.txt


Echo.gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif > %2\%3\%3_translate_log.txt

but neither works.

  • first to ' echo "command line with spaces" >> file.txt ' and after that execute command line in bat file (or do like i do, i got bash shell from git package and i do all my scripts in bash) – simpleuser001 Nov 22 '12 at 10:47
  • I don't understand <<echo "gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif" > %2\%3\1_%3_translate_log.txt >> just prints the line in the log.txt file. – GeorgeC Nov 22 '12 at 11:31
  • sorry, my bad i didn't understand question right. See R.K answer. it is working way to do it – simpleuser001 Nov 22 '12 at 13:26

Found this workaround at StackOverflow

gdal_translate -expand rgba -of GTiff -a_srs EPSG:3857 -co TILED=YES -co BIGTIFF=YES %1 %2\%3\%3_translated.tif >> %2\%3\%3_translate_log.txt | type a.txt %2\%3\%3_translate_log.txt

A caveat, this will echo to screen after it has been saved to file.

Or you can install a Windows port of the tee command that should do what you want.

  • thanks...the main reason for this question is to be able to see what's happening with the gdal_warp/retile.py etc as they give an output "0...10...20" or "pyramid 1012 created" etc. I can also just open the txt file and it still writes to it. I don't want to install tee or cygwin as getting gdal/python to work in it is very complex...can we echo the output to the shell and then pipe that to a txt file? – GeorgeC Nov 22 '12 at 12:59
  • Unfortunately, I don't think you can do that on Windows. There can only be one output if I'm not mistaken. I think tee isn't too complex. The format is just ` mycommand > tee outpu_file.txt` which should direct output to stdout and the file. – R.K. Nov 22 '12 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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