Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法将Powershell、Python脚本转换为Bash脚本?_Python_Bash_Powershell - Fatal编程技术网

有没有办法将Powershell、Python脚本转换为Bash脚本?

有没有办法将Powershell、Python脚本转换为Bash脚本?,python,bash,powershell,Python,Bash,Powershell,我为Windows操作系统开发了多个PowerShell脚本 检查内存利用率 改变服务状态 检索用户信息 我想为Linux和Mac OS开发相同的脚本,是否有任何方法可以使用现有的powershell脚本。您可能会发现此链接很有帮助: 它为您提供了如何安装powershell的指南,以及如何在bash中运行powershell脚本的一些示例。我想没有一种自动将ps转换为bash的方法,也没有一种在Linux上本机使用ps脚本的方法。您必须重写它们,使用bash、python、perl或您喜欢的任

我为Windows操作系统开发了多个PowerShell脚本

检查内存利用率 改变服务状态 检索用户信息


我想为Linux和Mac OS开发相同的脚本,是否有任何方法可以使用现有的powershell脚本。

您可能会发现此链接很有帮助:


它为您提供了如何安装powershell的指南,以及如何在bash中运行powershell脚本的一些示例。

我想没有一种自动将ps转换为bash的方法,也没有一种在Linux上本机使用ps脚本的方法。您必须重写它们,使用bash、python、perl或您喜欢的任何脚本语言,并考虑到windows以不同的方式工作

通过在.bat文件中执行以下操作,可以在.bat文件中调用python脚本:

python.exe路径指定python脚本的路径,然后将其另存为.bat文件


您可以通过在cmd上键入where python来获得可执行的python路径。

@Alderven:谢谢您的回答,我不能使用powershell执行,我必须编写bash脚本,我的问题是我已经有powershell脚本了,我可以将它们转换为bash脚本吗?谢谢您的回答,我不能使用powershell执行,我必须编写bash脚本,我的问题是我已经有了powershell脚本。我可以将它们转换为bash脚本吗指南I have链接向您展示了如何从bash脚本运行powershell脚本,但首先您必须在操作系统上安装powershell才能获得该功能。这不是你要找的吗?