根据函数的输出进入while循环 [英] sleep a while loop based on output from a function

查看:59
本文介绍了根据函数的输出进入while循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下方面需要您的帮助.我的.sh如下.

Need your help with the following. My .sh is as follows.

 getfunc (){

 if [condition 1]
 then
 echo "NOK" >flag
 else
 echo "OK" >flag
 fi
 }

 while IFS=" " read -r var1
 do
 getfunc
 if [ $flag -eq OK ]
 then
 "print 1"
 else 
 "sleep for sometime"
 fi
 done <file

我不知道该如何确定应定期尝试的时间,直到getfunc可以确定为止.

I don't know how to tell while to keep trying in regular intervals, till it gets OK from getfunc.

任何帮助将不胜感激.谢谢.

Any help is greatly appreciated. thanks.

推荐答案

  until [[condition]]
  do
  echo "sleeping"
  sleep 5
  done

这篇关于根据函数的输出进入while循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆