0

I was trying to get certain fastboot variables from a batch file. I was using something like :

for /f "tokens=2 delims=:" %%a in ('fastboot.exe getvar version-bootloader') do @echo version is %%a

But I get the output on command line, not in the variable %%a. the command 'fastboot.exe getvar version-bootloader' works perfectly in command-line. I also tried doing:

fastboot.exe getvar version-bootloader >> temp.txt

but temp.txt is always empty and i receive the output on the command line, instead of the file. Is there an alternative to this?

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Ankur Aggarwal
  • 2,210
  • 2
  • 34
  • 39
  • 1
    It seems that `fastboot.exe` don't use the stdout stream. You could try to redirect stream2. `fastboot.exe getvar version-bootloader 2> temp.txt` – jeb May 06 '12 at 20:21

1 Answers1

1

fastboot output is directed to error stream, you can direct error stream to standard stream by adding 2>&1

  1. your script will get two lines since fastboot getvar returns additional line with time elapsed.
  2. your script parses the version with a leading space, you shoud add a space to the delimiter (it is default but when you give delims it is overwritten)

you should use:

for /f "tokens=2 delims=: " %%a in ('fastboot.exe getvar version-bootloader 2^>^&1 ^| findstr version') do @echo version is %%a
Ofir Luzon
  • 10,635
  • 3
  • 41
  • 52