我试图从 shell 脚本返回一个字符串到 python 得到以下错误。
./whiptail.sh: 10: return: Illegal number: uuiiu
Run Code Online (Sandbox Code Playgroud)
我尝试在 python 中直接使用 subprocess.Popen 运行whiptail命令,即使那时我无法从 python 读取用户输入..如果有人尝试过这个,请告诉我如何解决这个问题。
外壳脚本片段
#!/bin/sh
COLOR=$(whiptail --inputbox "What is your favorite Color?" 8 78 Blue --title "Example Dialog" 3>&1 1>&2 2>&3)
# A trick to swap stdout and stderr.
# Again, you can pack this inside if, but it seems really long for some 80-col terminal users.
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "User selected Ok and entered " $COLOR
return $COLOR …Run Code Online (Sandbox Code Playgroud)