来自终端的 Linux powershell 命令返回未找到命令 [英] Linux powershell command from terminal returns command not found
本文介绍了来自终端的 Linux powershell 命令返回未找到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个运行带有 Powershell 的 Ubuntu Server 16.04 的 Linux 机器,如果我从 Linux 终端运行:
I have a Linux box running Ubuntu Server 16.04 with Powershell on it, from the Linux terminal if I run:
sudo powershell (Invoke-Webrequest http://ipinfo.io/json | ConvertFrom-Json).ip
我收到一条错误消息,说它的格式不正确,并希望在末尾有 ')'
.如果我删除 ()
并尝试从 JSON 转换它会抛出找不到命令 ConvertFrom-Json
.
I get an error saying it is formatted incorrectly and expected a ')'
at the end. if I remove the ()
and just try to convert from JSON it throws a could not find the command ConvertFrom-Json
.
也就是说,如果我真的进入 powershell 并运行原始命令,它会完美运行.
That said if I actually go into powershell and run the original command it works perfectly.
任何帮助将不胜感激.
推荐答案
我发现需要像这样包装命令
I figured it out need to wrap the command like this
sudo powershell '(Invoke-Webrequest http://ipinfo.io/json | ConvertFrom-Json).ip'
感谢您的帮助!
这篇关于来自终端的 Linux powershell 命令返回未找到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文