2

I run some code in python on windows and I get an error of " 'tee' is not recognized as an internal or external command, operable program or batch file. "

result = './model/%s/result.txt' % opt.name  # path of result.txt file
os.system('python evaluate_gpu.py | tee -a %s' % result)

I know tee does not exist on windows can anyone help me and write replace code for windows version

Thank all

djvg
  • 11,722
  • 5
  • 72
  • 103
m.safari
  • 21
  • 1
  • 2
  • 3
    Apparently Powershell has tee even if cmd doesn’t... I have no way of verifying this however! https://superuser.com/questions/74127/tee-for-windows –  May 02 '20 at 18:44
  • 1
    *tee* is not a Windows OS command. See https://en.wikipedia.org/wiki/Tee_(command) – Ken White May 02 '20 at 18:48
  • 2
    I just checked and you can use `tee` in powershell. To run powershell in python check the answers in https://stackoverflow.com/q/14508809/13357958 – SergioR May 02 '20 at 22:42
  • [tee in powershell docs](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7.2&viewFallbackFrom=powershell-7.1) – djvg Sep 21 '22 at 09:32

1 Answers1

4

First of all, you can download UnxUtils from http://sourceforge.net/projects/unxutils/?source=dlp. Then, you need to find tee.exe and move it to the folder of system32 in your pc.

  • A caveat here. If you use it in any script which you then share with someone else it will not work for them, leading to the "but it works in my machine"(tm) dialogue. "Anything that can go wrong, will go wrong" - Murphy – gk_2000 Nov 04 '21 at 19:24
  • This is really the right answer to this question – Matin Feb 02 '22 at 11:19