gpt4 book ai didi

linux - 在 Linux 对话框脚本中按 "}"时出现意外的 'Cancel'

转载 作者:太空宇宙 更新时间:2023-11-04 03:52:43 24 4
gpt4 key购买 nike

我试图找出为什么在以下对话框脚本中按“取消”时不断收到错误Unexpected }

在脚本编写方面我完全是个菜鸟。

#!/bin/sh
hdd=`fdisk -l | grep ^Disk | awk -F: "{ print $1 }"`
function dialog_menu {
dialog --title "Disktest" --menu "$hdd" 16 60 7 \
"badblocks -sv /dev/sda" "Read test on /dev/sda" \
"badblocks -wsv /dev/sda" "Read/Write test on /dev/sda" \
"badblocks -sv /dev/sdb" "Read test on /dev/sdb" \
"badblocks -wsv /dev/sdb" "Read/Write test on /dev/sdb" \
"badblocks -sv /dev/sdc" "Read test on /dev/sdc" \
"badblocks -wsv /dev/sdc" "Read/Write test on /dev/sdc" \
Exit "Exit disk test" 2>~/tmp ;

menuitem=`cat ~/tmp`
opt=$?

case $menuitem in
"badblocks -sv /dev/sda") var=`badblocks -sv /dev/sda`;
read;
dialog_menu ;;
"badblocks -wsv /dev/sda") var=`badblocks -wsv /dev/sda`;
read;
dialog_menu ;;
"badblocks -sv /dev/sdb") var=`badblocks -sv /dev/sdb`;
read;
dialog_menu ;;
"badblocks -wsv /dev/sdb") var=`badblocks -wsv /dev/sdb`;
read;
dialog_menu ;;
"badblocks -sv /dev/sdc") var=`badblocks -sv /dev/sdc`;
read;
dialog_menu ;;
"badblocks -wsv /dev/sdc") var=`badblocks -wsv /dev/sdc`;
read;
dialog_menu ;;
Exit) clear;
echo "Usage: badblocks -[w]sv /dev/[DEVICE]";
echo "$hdd";
exit;;
esac

clear
}
dialog_menu
rm ~/tmp

非常感谢我能得到的任何帮助!

最佳答案

好的,所以我在发送这个问题后就自己弄清楚了,不,} 应该在那里,因为它是函数的结尾。我刚刚在 esac 行之后添加了另一个“退出”行,它起作用了。不管怎样,谢谢你的帮助

关于linux - 在 Linux 对话框脚本中按 "}"时出现意外的 'Cancel',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25744279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com