本文介绍了你怎么能在bash上运行命令,直到成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个剧本,要问一些信息的用户,脚本无法继续下去,直到用户在这个信息填充。以下是我在把一个命令成一个圈来实现这一尝试,但它不会出于某种原因。

 回声请更改密码
而passwd文件

回声重试
DONE

我已经试过了while循环的许多变化:

 而`passwd`
而[[`passwd`-gt 0]
而[`passwd` -ne 0]
# ... 以及更多

但我似乎无法得到它的工作。


解决方案

 直到passwd文件

  回声重试
DONE

I have a script and want to ask the user for some information, the script cannot continue until the user fills in this information. The following is my attempt at putting a command into a loop to achieve this but it doesn't work for some reason.

echo "Please change password"
while passwd
do
echo "Try again"
done

I have tried many variations of the while loop:

while `passwd`
while [[ "`passwd`" -gt 0 ]]
while [ `passwd` -ne 0 ]]
# ... And much more

But I can't seem to get it to work.

解决方案
until passwd
do
  echo "Try again"
done

这篇关于你怎么能在bash上运行命令,直到成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 01:07