tee: 'standard output': Permission denied

Takashi Yano takashi.yano@nifty.ne.jp
Wed Dec 30 01:45:04 GMT 2020


On Wed, 30 Dec 2020 00:50:56 +0300
Andry via Cygwin <cygwin@cygwin.com> wrote:
> Hello Cygwin,
> 
>   >I am trying to change directory before run a bash shell with login:
> 
>   I've minimized to a minimal example to repro the issue:
> 
>   *run_cygwin_bash.bat*:
> 
>   ```
>   @echo off
> 
>   set CYGWIN_ROOT=...
>   set PWD=...
>   set PROJECT_LOG_FILE=...
> 
>   chcp.com 65001 >nul
> 
> 
>   "%CYGWIN_ROOT%\bin\bash.exe" -c "{ cd ""%PWD:\=/%""; CHERE_INVOKING=. ""%CYGWIN_ROOT:\=/%/bin/bash.exe"" -l -i; } 2>&1 | ""%CYGWIN_ROOT:\=/%/bin/tee.exe"" -a ""%PROJECT_LOG_FILE:\=/%"""
>   ```
> 
>   To execute:
> 
>   ```
>   c:\> start "" cmd.exe /C run_cygwin_bash.bat
> 
>   ```
> 
>   To stall:
> 
>   ```
>   $ 123
>   c:/cygwin/bin/tee: 'standard output': Permission denied
>   ```
> 
>   It repro only if:
> 
>   `chcp.com 65001` used together with `start "" cmd.exe ...`

I cannot reproducue your problem even with chcp.com 65001 and
start "" cmd.exe ...

By the way, using tee for logging the output is not good
idea because stdout is not a tty. Due to this, less command
does not work properly.

Instead, I recommend:

@echo off
set CYGWIN_ROOT=...
set PROJECT_LOG_FILE=...

"%CYGWIN_ROOT%\bin\script" -q -a "%PROJECT_LOG_FILE%" -c "chcp.com 65001 > /dev/null 2>&1; /bin/bash --login"


-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin mailing list