bash - 尝试在 if 中添加两个条件
问题描述
我正在尝试执行这个 bash 脚本,我正在尝试加入域。
domainjoin-cli
加入后$Domain
它会提示输入密码,如果我的密码错误,我希望脚本退出并显示一条消息“不成功”,如果另一方面它是正确的密码,我需要它来继续脚本的其余部分。
#!/bin/bash
echo -n "Domain: "
read Domain
domainjoin-cli join $Domain
if [[ "$password" = 'SUCCESS' ]]
then
echo "SUCCESS"
ls -l
fi
echo
if [[ "$password" = 'Error' ]]
then
echo "Not SUCCESSFULL"
exit
fi
如果我执行脚本,我会收到此错误消息:
3.sh: 5: 3.sh: [[: not found
3.sh: 10: 3.sh: [[: not found
这是密码错误时的输出:
"Error: LW_ERROR_PASSWORD_MISMATCH [code 0x00009c56] The password is incorrect for the given account"
如果密码正确,这是输出:
"Warning: System restart required Your system has been configured to authenticate to Active Directory for the first time. It is recommended that you restart your system to ensure that all applications recognize the new settings.
SUCCESS"
解决方案
推荐阅读
- c# - 如何获取 C# 方法调用中执行的行数?
- scala - Simulacrum:找不到宏实现
- dart - 如何在 Dart 中导入本地创建的包?
- orientdb - OrientDB:如何在 orientdb 中按节点过滤 Edge
- angular - “错误:没有 Sugerir 的提供者!” 在 ionic 3 打字稿/角度应用程序中
- javascript - 在输入文本中使用粘贴时数据过滤器不起作用
- c# - 使用数组进行独特行程选择的最佳性能算法?
- c# - 如何获取内联 xml 架构?
- python - matplotlib.mathtext 函数返回 Unknown symbol: \begin{} 即使 usetex=True 和 \usepackage{amsmath} 正确配置
- python - 在 3.x 程序中有条件地执行部分 python 代码作为 2.x