【问题标题】:Can't Activate Document in Pipeline (unix script)无法在管道中激活文档(unix 脚本)
【发布时间】:2015-07-20 12:37:25
【问题描述】:

我正在尝试使用 Powershell 运行bayes-seg 程序:cat data/books/clinical/050.ref | ./segment config/dp.config

我了解命令cat 输出文件,pipe 将使用输出作为./segment config/dp.config 的参数

运行上述命令时。我遇到了例外:

Cannot run a document in the middle of a pipeline: C:\Users\name\Desktop\bayes-seg-master\segment.
At line:1 char:35
+ cat data/books/clinical/050.ref | ./segment config/dp.config
+ CategoryInfo: InvalidOperation: (C:\Users\name\...-master\segment:String) [], RuntimeException
+ FullyQualifiedErrorId : CantActivateDocumentInPipeline

是什么导致了这个异常?我在谷歌上环顾四周,找不到任何详细解释异常的东西。任何帮助将不胜感激。

【问题讨论】:

  • 您找到解决方案了吗?
  • 不,这是将我推向 linux 的许多最后一根稻草之一。从那以后再也没有回头。
  • 奇怪。其他外部命令工作正常:cat file1 | findstr 1,假设 segment.exe 采用管道输入。
  • 那个网站说segment是一个unix脚本。它不会在 Windows 中运行。
  • 由于这是一个无法在 Windows 中运行的 unix 脚本,我将关闭它。

标签: powershell powershell-2.0 powershell-3.0


【解决方案1】:

由于可执行文件 segment.exe 不了解 PowerShell 样式管道,因此您必须使用 ForEach-Objectsegment.exe 指定特定参数:

cat data/books/clinical/050.ref | %{ ./segment config/dp.config $_ }

由于我不知道此可执行文件的用法,您可能需要根据需要调整参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-30
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    相关资源
    最近更新 更多