简体   繁体   中英

Is there any way to convert Powershell,Python script to Bash script?

I have developed multiple PowerShell scripts for Windows OS

Check Memory utilization Changing service state Retrieving User Information.

i want to develop the same scripts for Linux and Mac OS, is there any way i can use existing powershell scripts.

You might find this link helpful:

https://www.phillipsj.net/posts/using-powershell-scripts-from-bash

It gives you a guide on how to install power shell and then some examples on how to run the powershell scripts in bash.

I suppose there is not an automagical way to convert ps to bash nor to use ps scripts natively on Linux. You have to rewrite them, using bash, python, perl or whatever scripting language you prefer and considering that windows works in a different way.

You can call your python script in the .bat file by doing the following in your .bat file:

"python.exe path" "the path for your python script" and then save it as a .bat file.

You can get the executable python path by typing "where python" on your cmd.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM