Help with bash script (if/case statement)
Posted on 2009-07-15
I'm trying to get a shell script to work but getting nowhere fast. Am sure that someone better at bash scripts than me could do this in their sleep!
I have a drbd process that spits out the following string when it's working:
[root@node1 bin]# cat /proc/drbd
version: 8.0.13 (api:86/proto:86)
GIT-hash: ee3ad77563d2e87171a3da17cc002ddfd1677dbe build by buildsvn@c5-x8664-build, 2008-10-03 10:12:56
0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---
ns:364186416 nr:0 dw:6410824 dr:357810242 al:5453 bm:22396 lo:0 pe:0 ua:0 ap:0
resync: used:0/61 hits:23851932 misses:27468 starving:0 dirty:0 changed:27468
act_log: used:0/257 hits:1597253 misses:302538 starving:1172 dirty:297066 changed:5453
What I've been doing is grep'ing out the most of that, like so:
[root@node1 bin]# cat /proc/drbd | grep Connected | cut -c 5-59
cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate
What I want to do is test for the string in a script, and if its present return 1 if not 0.
If anybody could offer some assistance i'd be very grateful!