I need to write a script that checks on the status of something. If the status Copying then exit (or retry in 60 minutes if we want to get fancy.) If all there is nothing returned (based on my second command, ie, everything is in sync) then do something else. If copying; exit or retry in 60If NULL; do more things.root@box:~$ ./prog status  PyDsk /home       In Sync  PyDsk /trax       Copying 85% complete  PyDsk /trax2      In Sync  PyDsk /trax3      Copying 97% complete  PyDsk /traxnl     Copying 50% complete  PyDsk /traxnl2    Copying 69% complete  PyDsk /traxnl3    Copying 56% complete  PyDsk /traxnl4    In Sync  PyDsk /traxnv     In Sync  PyDsk /traxnv2    In Sync  PyDsk /ulog       In Syncroot@box:~$ ./prog status | grep complete | awk '{print $3;}'CopyingCopyingCopyingCopyingCopyingedit; I'm open to any other way of getting this done. I'm not married to how I've started things... it's just the only way I could think of. If there's something more elegant, I'll take it :)edit2; redacted. I'm going dark.
help with script; if status is this do that if not do something else
bash;shell script;scripting
I'm new to the bash programming. Therefore, it is very likely that someone may present a more elegant solution but here is mine;#!/bin/bashcount=`./prog status | grep complete | awk '{print $3}' | wc -l`zero=0if [ $count -eq $zero ]then echo all done.else echo wait a little more and try again.fiCount variable is the number of copy operations. If count is equal to zero, which means there is no copy operation in progress, then the script prints all done, otherwise it prints wait a little more and try again. You can change the lines containing echo with your own commands. Hope it helps.