tee: 'standard output': Permission denied

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

tee: 'standard output': Permission denied

Cygwin list mailing list
Hello Cygwin,

  I am trying to change directory before run a bash shell with login:

  "%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:\=/%"""

  , where:

  CYGWIN_ROOT - path to cygwin root directory
  PWD - arbitrary working directory to run bash from
  PROJECT_LOG_FILE - path to log file to log stdout+stderr

  Currently this throws the error: `tee: 'standard output': Permission
  denied` if try to type not valid command or expression, and input is
  stalls.

  The same behaviour in the msys.

  Do anyone have a solution?

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

tee: 'standard output': Permission denied

Cygwin list mailing list
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 ...`

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
On Tuesday, December 29, 2020, 04:47:56 PM EST, Andry via Cygwin <[hidden email]> wrote:

>  "%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:\=/%"""
  ```

Cannot repro...  Logfile is created correctly and commands and their output are logged there.  The file encoding for the logfile is utf-8.
A couple of things though:    1.  changing \ to / does not guarantee a valid Cygwin path.    2.  the cd does nothing because bash -l starts the shell in the home directory.    3.  Once you've started bash, you don't have to supply the full path so "/bin/bash.exe" and "/bin/tee.exe" are fine (assuming your path and mounts are set correctly)
Are any files on a remote share?Are any of the paths relative?Do any of the paths have spaces in them?
You should check out the cygpath utility...
Kevin  
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
On Tue, 29 Dec 2020 at 14:48, Andry via Cygwin <[hidden email]> wrote:

>
>   "%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:\=/%"""
>   ```
>

In most situations like this, I  create a bash script containing everything
I want to do within bash. Trying to get all the quoting right is a pain in
the brain.

The key lines in my .bat files (with CRLF endings) are:

set D=folder  *the directory containing script
set SCRIPT=script.sh   *the name if the bash script file (with LF endings)
set BASH=C:\cygwin64\bin\bash.exe
%BASH% --noprofile -o errexit -o nounset -c %D%/%SCRIPT%

Note the forward slash between script directory and script file, very
important!
Also note there is no quoting required - a big win.

First command in the bash script is usually an "export PATH=..." command.

Of course, if there is an actual permissions error, this will not fix it,
but it will allow you to more easily diagnose the problem.

HTH
Doug

--
Doug Henderson, Calgary, Alberta, Canada - from gmail.com
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
On Wed, 30 Dec 2020 00:50:56 +0300
Andry via Cygwin <[hidden email]> 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 <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello Kometes,

  >Cannot repro...  Logfile is created correctly and commands and their output are logged there.  The file encoding for the logfile is utf-8.
  The issue found in the Windows 7 x64.

  >A couple of things though:    1.  changing \ to / does not guarantee a valid Cygwin path.
  Not sure what you talking about. Always worked.

  >2.  the cd does nothing because bash -l starts the shell in the home directory.
  I've tested it and it does.

  >3.  Once you've started bash, you don't have to supply the full path so "/bin/bash.exe" and "/bin/tee.exe" are fine (assuming your path and mounts are set correctly)
  You have to, because not logged shell does not have PATH registration to the `/bin`.

  >Are any files on a remote share?
  You cannot run cmd.exe on a remote share.

  >Are any of the paths relative?Do any of the paths have spaces in them?
  Does it matter?

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello takashi,

>I cannot reproducue your problem even with chcp.com 65001 and
>start "" cmd.exe ...
Seems this is a bug specifically for the Windows 7 x64.

>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.
That  is  way  to  not  break the cygwin colorization and I don't want
to start  a  script,  all  I  want  is to start an interactive console in
an arbitrary working directory.

>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"
That is not an equivalent, there is no directory to switch to BEFORE the login.

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
On Wed, 30 Dec 2020 05:24:02 +0300
Andry wrote:

> Hello takashi,
>
> >I cannot reproducue your problem even with chcp.com 65001 and
> >start "" cmd.exe ...
> Seems this is a bug specifically for the Windows 7 x64.
>
> >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.
> That  is  way  to  not  break the cygwin colorization and I don't want
> to start  a  script,  all  I  want  is to start an interactive console in
> an arbitrary working directory.
>
> >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"
> That is not an equivalent, there is no directory to switch to BEFORE the login.

I am not sure why you don't wat to use script,
how about this then?

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

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

--
Takashi Yano <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
On Wed, 30 Dec 2020 13:02:58 +0900
Takashi Yano via Cygwin <[hidden email]> wrote:
> I am not sure why you don't wat to use script,
> how about this then?
>
> @echo off
> set CYGWIN_ROOT=...
> set PWD=...
> set PROJECT_LOG_FILE=...
>
> "%CYGWIN_ROOT%\bin\script" -q -a "%PROJECT_LOG_FILE%" -c "chcp.com 65001 > /dev/null 2>&1; cd \"%PWD%\"; CHERE_INVOKING=1 /bin/bash --login"

or:

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

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

--
Takashi Yano <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello Cygwin,

  >I am not sure why you don't wat to use script,
  >how about this then?
  >
  >@echo off
  >set CYGWIN_ROOT=...
  >set PWD=...
  >set PROJECT_LOG_FILE=...
  >
  >"%CYGWIN_ROOT%\bin\script" -q -a "%PROJECT_LOG_FILE%" -c "chcp.com 65001 > /dev/null 2>&1; cd \"%PWD%\"; CHERE_INVOKING=1 /bin/bash --login"

  1. chcp.com has no effect here
  2. log is written after the `script` exit

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello takashi,

>or:
>...
>
>cd "%PWD%"

This does not work with long 260+ paths.

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
On Wed, 30 Dec 2020 07:49:07 +0300
Andry wrote:

> Hello Cygwin,
>
>   >I am not sure why you don't wat to use script,
>   >how about this then?
>   >
>   >@echo off
>   >set CYGWIN_ROOT=...
>   >set PWD=...
>   >set PROJECT_LOG_FILE=...
>   >
>   >"%CYGWIN_ROOT%\bin\script" -q -a "%PROJECT_LOG_FILE%" -c "chcp.com 65001 > /dev/null 2>&1; cd \"%PWD%\"; CHERE_INVOKING=1 /bin/bash --login"
>
>   1. chcp.com has no effect here

Weird. In my environment, chcp surely changes the code page.
Are you using cygwin 3.2.0 snapshot by any chance? If so, add
set CYGWIN=disable_pcon
before starting script.

>   2. log is written after the `script` exit

Add -f option to script command.

--
Takashi Yano <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello Cygwin,

  One more issue with the script is that the line returns forces at
  some points as CR. When run bash from cmd.exe - CR+LF

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
Hello Cygwin,

  >Weird. In my environment, chcp surely changes the code page. Are you using cygwin 3.2.0 snapshot by any chance?

  Yes, in 3.1.x (cygwin64) it works.
  But the issue with the mixed CR / CR+LF in the log is still persist.

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
On Wed, 30 Dec 2020 14:03:58 +0900
Takashi Yano via Cygwin <[hidden email]> wrote:

> On Wed, 30 Dec 2020 07:49:07 +0300
> Andry wrote:
> > Hello Cygwin,
> >
> >   >I am not sure why you don't wat to use script,
> >   >how about this then?
> >   >
> >   >@echo off
> >   >set CYGWIN_ROOT=...
> >   >set PWD=...
> >   >set PROJECT_LOG_FILE=...
> >   >
> >   >"%CYGWIN_ROOT%\bin\script" -q -a "%PROJECT_LOG_FILE%" -c "chcp.com 65001 > /dev/null 2>&1; cd \"%PWD%\"; CHERE_INVOKING=1 /bin/bash --login"
> >
> >   1. chcp.com has no effect here
>
> Weird. In my environment, chcp surely changes the code page.
> Are you using cygwin 3.2.0 snapshot by any chance? If so, add
> set CYGWIN=disable_pcon
> before starting script.

Sorry, I was wrong.

As for Win7, chcp should work without disable_pcon even in
cygwin 3.2.0, because pseudo console is not activated under Win7.

--
Takashi Yano <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Cygwin list mailing list
In reply to this post by Cygwin list mailing list
On Wed, 30 Dec 2020 05:24:02 +0300
Andry wrote:
> Hello takashi,
>
> >I cannot reproducue your problem even with chcp.com 65001 and
> >start "" cmd.exe ...
> Seems this is a bug specifically for the Windows 7 x64.

I guess the problem is essentially the same with followings.

In Win7,
1) Start command prompt.
2) Run chcp 65001
3) Change the font of command prompt to raster font.
4) Run c:\cygwin\bin\printf "\xce\b1\n"

This causes the error:
/usr/bin/printf: write error

What weird is that if the font is other than raster font,
this error does not occur.

I looked into this problem and found that the following
simple c code does not work in command prompt with chcp
65001 and raster font in Win7.

/* Compile this code using MinGW compiler
   and run in cmd.exe */
#include <windows.h>
#include <stdio.h>

int main()
{
    wchar_t wstr[] = L"α\r\n";
    HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD n;
    int ret = WriteConsoleW(h, wstr, wcslen(wstr), &n, NULL);
    printf("n=%d, ret=%d, Err=0x%08x\n", n, ret, GetLastError());
    return 0;
}

This is also reproducible in legacy console mode of windows10.

The error code is 0x0000001f (ERROR_GEN_FAILURE: A device attached to
the system is not functioning).

Is this possibly a bug of windows?

--
Takashi Yano <[hidden email]>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: Re: tee: 'standard output': Permission denied

Andry-2
Hello Cygwin,

  >What weird is that if the font is other than raster font, this error does not occur.
  Sad, but seems the version of the cygwin is not related to the
  issue, it still fails in the cygwin64 3.1.x: `script: write failed: Permission denied`

  >Is this possibly a bug of windows?
  May  be  default  `Terminal`  console font in the Windows 7 does not
  have a required character to draw?

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

Re: tee: 'standard output': Permission denied

Brian Inglis
In reply to this post by Cygwin list mailing list
On 2020-12-29 19:22, Andry via Cygwin wrote:

>> Cannot repro...  Logfile is created correctly and commands and their
>> output are logged there.  The file encoding for the logfile is utf-8.
> The issue found in the Windows 7 x64.
>
>> A couple of things though:    1.  changing \ to / does not guarantee a
>> valid Cygwin path.
> Not sure what you talking about. Always worked.
>
>> 2.  the cd does nothing because bash -l starts the shell in the home
>> directory.
> I've tested it and it does.
>
>> 3.  Once you've started bash, you don't have to supply the full path so
>> "/bin/bash.exe" and "/bin/tee.exe" are fine (assuming your path and mounts
>> are set correctly)
> You have to, because not logged shell does not have PATH registration to the
> `/bin`.
>
>> Are any files on a remote share?
> You cannot run cmd.exe on a remote share.
>
>> Are any of the paths relative?Do any of the paths have spaces in them?
> Does it matter?
Seems to have been reported a few times with Windows Russian and fix suggested
was "chcp 1252" (which might not be too useful for many Russians), as there may
be encoding conversion bugs with UTF-8.

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
Reply | Threaded
Open this post in threaded view
|

tee: 'standard output': Permission denied

Andry-2
Hello Brian,

  >Seems to have been reported a few times with Windows Russian and fix suggested
  >was "chcp 1252" (which might not be too useful for many Russians), as there may
  >be encoding conversion bugs with UTF-8.
  Why  not  just switch a console to TrueType font like Lucida Console
  or installed Consolas font from Visual Studio?

  You  even can install, for example, vectorized raster variant of the
  Fixedsys/Terminal font like TerminalVectorized font: http://www.yohng.com/software/terminalvector.html
  (Simply  click  on  font,  press install button and restart console.
  Almost  looks  like the  same  Fixedsys, but has a bit different `0`
  character)

  Or  install  another  not  vectorized raster variant, like, Terminus
  font: http://terminus-font.sourceforge.net
  (not sure how to replace, not found a solution on the internet)

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple