gpt4 book ai didi

powershell - Powershell脚本输出到变量-捕获Write-Host输出

转载 作者:行者123 更新时间:2023-12-02 23:09:02 26 4
gpt4 key购买 nike

使用此脚本:https://github.com/byterogues/powershell-bittrex-api
我从另一个脚本调用。

例如

$order = .\bittrex-api.ps1 -action buylimit -market BTC-TX -quantity 1 -rate 0.00011300

bittrex-api.ps1捕获错误并在屏幕上显示此错误

BITTREX错误:API查询返回错误。
错误消息:MIN_TRADE_REQUIREMENT_NOT_MET

如何将bittrex-api.ps1的输出捕获到变量中,以便可以在基本脚本中使用此变量?

最佳答案

你不能该脚本使用Write-Host输出错误。 Write-Host仅将文本写入控制台,它不返回任何对象,这意味着没有要捕获的对象。

我建议您修改脚本以使用其他cmdlet(例如Write-ErrorWrite-Output或输出到流(您可以重定向到stdout-stream并保存)的任何其他Write-*)。

参见http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/

关于powershell - Powershell脚本输出到变量-捕获Write-Host输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49087085/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com