【问题标题】:The '<' operator is reserved for future use'<' 运算符保留供将来使用
【发布时间】:2010-01-27 16:55:15
【问题描述】:

我正在使用 PowerShell 并尝试运行以下命令:

.\test_cfdp.exe < test.full | tee test.log

test.full 是一个模拟 test_cfdp.exe 命令行输入的脚本。但是,我收到以下错误:

The '<' operator is reserved for future use.

我可以使用另一种方式(即 cmdlet)来让这个命令在 PowerShell 中工作吗?

【问题讨论】:

    标签: powershell redirect io-redirection


    【解决方案1】:

    这个was not supported in PowerShell v1 [从 v5 开始,它仍然不是...]

    一个示例解决方法是:

    Get-Content test.full | .\test_cfdp.exe | tee test.log
    

    【讨论】:

      【解决方案2】:

      也试试:

      cmd /c '.\test_cfdp.exe < test.full | tee test.log'
      

      【讨论】:

        【解决方案3】:

        我已经切换到 linux shell 并且可以正常工作

        【讨论】:

          【解决方案4】:

          如果您想多次运行此命令,您可以使用原始语法创建一个 *.bat 文件。这是另一种解决方案。

          【讨论】:

            【解决方案5】:

            在 PowerShell 版本 7 中,您仍然需要使用 Get-Content 来获取指定位置中项目的内容。 例如,如果您想将文件加载到 Python 脚本中并将结果写入文件。使用这个结构:

            PS > Get-Content input.txt | python .\skript.py > output.txt
            

            或显示并保存在文件中:

            PS > Get-Content input.txt | python .\skript.py | tee output.txt
            

            或者切换到cmd使用'

            C:\>python .\skript.py < input.txt > output.txt
            

            【讨论】:

              猜你喜欢
              • 2020-06-16
              • 1970-01-01
              • 2014-09-23
              • 2021-04-27
              • 1970-01-01
              • 1970-01-01
              • 2022-12-21
              • 1970-01-01
              • 2012-05-22
              相关资源
              最近更新 更多