我正在嘗試從這里使用 Wireguard road-warrior 腳本https://github.com/Nyr/wireguard-install
但我不能讓它在具有預定義引數的非互動模式下運行。我在這里閱讀了一些其他類似的主題,關于如何為 bash“閱讀”提供答案,但那里的建議不起作用。
我試過這個:
# bash wireguard-install.sh < params
# printf '%s\n' 51822 clientcustom 2 y | bash wireguard-install.sh
# echo "51822 clientcustom 2 y" | bash wireguard-install.sh
在每種情況下,安裝程式都只使用默認值。我究竟做錯了什么?
uj5u.com熱心網友回復:
https://github.com/Nyr/wireguard-install/blob/master/wireguard-install.sh#L15
確實,這有點問題。通常,不在乎,您只會:
( sleep 1; printf '%s\n' 51822 clientcustom 2 y ) | ...
一個真正強大的解決方案,您將決議行程的輸出以了解何時撰寫回應,無論是使用期望還是 Bash 或更好的東西。
coproc bash wireguard-install.sh
while IFS= read -r -u "${COPROC[0]}" line; do
case "$line" in
"IPv4 address [1]:"*) echo something >&"${COPROC[1]}"; ;;
"other prompt"*) echo other stuff >&"${COPROC[1]}"; ;;
"etc...") echo ... ;;
esac
done
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/439454.html
標籤:重击
下一篇:床具安裝問題
