WineでWindowsコマンドラインプログラムのstdoutリダイレクト

WineでWindowsコマンドラインプログラムのstdoutリダイレクト

私は Wine を使って Windows コマンドラインプログラム (アクセス権がない) を実行します。明らかに、標準出力に何かを書いていますが、その出力をキャプチャしようとしていますが、リダイレクトできません。

stdoutまたはstderrをファイルにリダイレクトするかどうかにかかわらず、プログラム出力は依然としてコンソールに印刷され、ファイルに書き込まれません。 stderrをリダイレクトするとワイン出力は消えますが、プログラム出力はまだ画面に印刷されます。

wine program.exe > out   # File is empty, program output printed on screen
wine program.exe 2> out  # Wine output gets redirected to file, program output still printed on screen

両方ともリダイレクトすると、出力は画面に印刷されず、ファイルに書き込まれません。

編集する:Windowsでは動作は似ていますが、両方ともリダイレクトすると、すべてがまだ画面に印刷されます。

以下は、完全な出力を含むいくつかの例です。

$ wine program.exe
fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches.
fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org.

output by program.exe

fixme:msvcrt:__clean_type_info_names_internal (0x100aaa54) stub

出力をリダイレクトしようとすると、これが発生します。

$ wine program.exe > out 2>&1
$ cat out
fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches.
fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org.
fixme:msvcrt:__clean_type_info_names_internal (0x100aaa54) stub

つまり、プログラムのコンソール出力が完全に失われます。プログラムはまだうまく機能し、期待どおりにいくつかのファイルを作成します。確認次元でpngcrushで同じことを行い、期待した結果を得ました。リダイレクトなし:

$ wine pngcrush_1_8_10_w32.exe test.png out.png
fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches.
fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org.

 | pngcrush-1.8.10
 |    Copyright (C) 1998-2002, 2006-2016 Glenn Randers-Pehrson
 |    Portions Copyright (C) 2005 Greg Roelofs
 | This is a free, open-source program.  Permission is irrevocably
 | granted to everyone to use this version of pngcrush without
 | payment of any fee.
 | Executable name is pngcrush_1_8_10_w32.exe
 | It was built with   bundled libpng-1.6.26
 | and is running with bundled libpng-1.6.26
 |    Copyright (C) 1998-2004, 2006-2016 Glenn Randers-Pehrson,
 |    Copyright (C) 1996, 1997 Andreas Dilger,
 |    Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
 | and bundled zlib-1.2.8.1-motley, Copyright (C) 1995 (or later),
 |    Jean-loup Gailly and Mark Adler,
 | and using "clock()".
 | It was compiled with gcc version 4.8.0 20121015 (experimental).

  Recompressing IDAT chunks in test.png to out.png
   Total length of data found in critical chunks            =    431830
   Critical chunk length, method   1 (ws 15 fm 0 zl 4 zs 0) =    495979
   Critical chunk length, method   2 (ws 15 fm 1 zl 4 zs 0) >    495979
   Critical chunk length, method   3 (ws 15 fm 5 zl 4 zs 1) =    495354
   Critical chunk length, method   6 (ws 15 fm 5 zl 9 zs 0) =    457709
   Critical chunk length, method   9 (ws 15 fm 5 zl 2 zs 2) >    457709
   Critical chunk length, method  10 (ws 15 fm 5 zl 9 zs 1) =    451813
   Best pngcrush method        =  10 (ws 15 fm 5 zl 9 zs 1) =    451813
     (4.63% critical chunk increase)
     (4.63% filesize increase)

CPU time decode 4.407583, encode 17.094248, other 4294967296.000000, total 17.180143 sec

リダイレクトの使用:

$ wine pngcrush_1_8_10_w32.exe test.png out.png > out 2>&1
$ cat out
fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches.
fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org.

 | pngcrush-1.8.10
 |    Copyright (C) 1998-2002, 2006-2016 Glenn Randers-Pehrson
 |    Portions Copyright (C) 2005 Greg Roelofs
 | This is a free, open-source program.  Permission is irrevocably
 | granted to everyone to use this version of pngcrush without
 | payment of any fee.
 | Executable name is pngcrush_1_8_10_w32.exe
 | It was built with   bundled libpng-1.6.26
 | and is running with bundled libpng-1.6.26
 |    Copyright (C) 1998-2004, 2006-2016 Glenn Randers-Pehrson,
 |    Copyright (C) 1996, 1997 Andreas Dilger,
 |    Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
 | and bundled zlib-1.2.8.1-motley, Copyright (C) 1995 (or later),
 |    Jean-loup Gailly and Mark Adler,
 | and using "clock()".
 | It was compiled with gcc version 4.8.0 20121015 (experimental).

  Recompressing IDAT chunks in test.png to out.png
   Total length of data found in critical chunks            =    431830
   Critical chunk length, method   1 (ws 15 fm 0 zl 4 zs 0) =    495979
   Critical chunk length, method   2 (ws 15 fm 1 zl 4 zs 0) >    495979
   Critical chunk length, method   3 (ws 15 fm 5 zl 4 zs 1) =    495354
   Critical chunk length, method   6 (ws 15 fm 5 zl 9 zs 0) =    457709
   Critical chunk length, method   9 (ws 15 fm 5 zl 2 zs 2) >    457709
   Critical chunk length, method  10 (ws 15 fm 5 zl 9 zs 1) =    451813
   Best pngcrush method        =  10 (ws 15 fm 5 zl 9 zs 1) =    451813
     (4.63% critical chunk increase)
     (4.63% filesize increase)

CPU time decode 4.339310, encode 17.137527, other 4.294083, total 17.182100 sec

他のプログラムが機能しないのはなぜですか?

ワイン標準出力標準エラーIOリダイレクト

ベストアンサー1

tmux端末マルチプレクサを使用して標準出力をキャプチャできます。capture-pane

おすすめ記事