Domanda

Lo script funziona correttamente quando stdout / stderr non vengono reindirizzati.

Quando aggiungo sia il reindirizzamento stderr che stdout, ottengo il seguente errore: Come posso evitarlo?

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0 19.4M    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 81 19.4M    0     0   81 15.9M      0  54.5M --:--:-- --:--:-- --:--:-- 55.8M
100 19.4M    0     0  100 19.4M      0  14.2M  0:00:01  0:00:01 --:--:-- 14.3M
100 19.4M    0     0  100 19.4M      0  8428k  0:00:02  0:00:02 --:--:-- 8454k
100 19.4M    0     0  100 19.4M      0  5924k  0:00:03  0:00:03 --:--:-- 5937k
100 19.4M    0     0  100 19.4M      0  4567k  0:00:04  0:00:04 --:--:-- 4575k
100 19.4M    0    50  100 19.4M     10  4291k  0:00:04  0:00:04 --:--:--  835k
out-lineoutput : The OS handle's position is not what FileStream expected. Do not use a handle simu
ltaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss.
    + CategoryInfo          : NotSpecified: (:) [out-lineoutput], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.OutLineOutputCom 
   mand
È stato utile?

Soluzione

Lee Holmes (uno degli sviluppatori senior del team PowerShell) tratta questo qui in un post sul blog:

http://www.leeholmes.com/blog/WorkaroundTheOSHandlesPositionIsNotWhatFileStreamExpected.aspx

Questo è un bug in PowerShell v1.0 e si verifica quando:

  • un comando di PowerShell genera sia output regolari che di errore
  • hai utilizzato cmd.exe per reindirizzare l'output su un file
  • hai utilizzato cmd.exe per unire i flussi di output e di errore

Esiste una soluzione alternativa.

-Oisin

Altri suggerimenti

Una volta avevo diverse giunzioni hard-link nella directory che dovevano avere " GetItemChild " applicato e ha ricevuto lo stesso errore di questa domanda.

La rimozione delle giunzioni ha risolto il problema.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top