[英]Convert bash into powershell script?
我需要轉換腳本:
s#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage:"
echo ${0##*/}" <port>"
echo
exit 1
fi
r=`ss -ln6tp | grep -c ":::$1"`
if [ $r -ne 1 ]; then
echo "Agent on port $1 is not listening."
exit_code=2
else
echo "Agent listening on port $1"
exit_code=0
fi
exit $exit_code
我完全沒有使用bash的經驗,而我的powershell知識是基礎知識。 退出代碼是我這里遇到的主要問題。 有什么想法嗎?
上述SO問題應該有助於解決您的問題。 它們將幫助您了解bash腳本的功能以及采用方法。 exit_code
用兩種語言定義腳本的返回。 如果要使用相同的邏輯將腳本完全轉換為PowerShell,將很難真正替換腳本的實際功能。 如果更改邏輯,則可能用單行替換它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.