標準輸出為空

標準輸出為空

當運行命令時:

cellprofiler --get-batch-commands "/users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5"

在 shell 中,我得到一個輸出:

CellProfiler -c -r -b -p /users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5 -g Metadata_Plate=20140602-LOPAC pilot_Assay Plate 0_5
CellProfiler -c -r -b -p /users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5 -g Metadata_Plate=20140602-LOPAC pilot_Assay Plate 0_6
CellProfiler -c -r -b -p /users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5 -g Metadata_Plate=20140602-LOPAC pilot_Assay Plate 0_7
CellProfiler -c -r -b -p /users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5 -g Metadata_Plate=20140602-LOPAC pilot_Assay Plate 0_8

但是,當我嘗試將其輸出到文件(我添加>test.txt)時,我得到一個空文件。我還嘗試透過 python 呼叫該命令並獲得空的標準輸出。在這兩種情況下,stderr 也是空的。

問題是什麼?有任何想法嗎?

答案1

有些程式在連接到終端機時和未連接到終端時的行為有所不同(請參閱isatty功能)。要使應用程式認為它已連接到終端,您可以嘗試script -c

script -c cellprofiler --get-batch-commands \
 "/users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5" \
  >test.txt

相關內容