Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Trying to make a resync script

Shell Programming and Scripting


Tags
grep, grep -q, scripts, solved

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 3 Weeks Ago
Stellaman1977 Stellaman1977 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 19 October 2017, 10:38 AM EDT
Posts: 6
Thanks: 6
Thanked 0 Times in 0 Posts
Trying to make a resync script

Good Morning,

I'm trying to automate the resync process after a mirror replacement on Solaris. To avoid resyncing all the drives at once, I'm trying to use metastat for each drive to determine if the drive is still resyncing or if it is done (Okay). The following test lines seem to always show false, while removing the "!" always shows true. In other words, it doesn't translate "Resyncing" or Okay" into true/false results:


Code:
While !(metastat d1 | grep "Resyncing" | wc -l | cut -f1 -d' '; do echo ResyncFound; sleep 5; done


Code:
While !(metastat d1 | grep "Okay" | wc -l | cut -f1 -d' '; do echo Okay; sleep 5; done

Any ideas on how to translate "Resyncing" into true?


Moderator's Comments:
Trying to make a resync script Please use CODE tags as required by forum rules!

Last edited by RudiC; 3 Weeks Ago at 11:00 AM.. Reason: Added CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 3 Weeks Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 October 2017, 2:22 PM EDT
Location: Aachen, Germany
Posts: 11,479
Thanks: 310
Thanked 3,561 Times in 3,276 Posts
Welcome to the forum.

Did you consider evaluating grep's exit code?
And, I'm not sure what that construct be: !( , even more when the closing parenthesis seems to be missing? Shouldn't while be lower case?
The Following User Says Thank You to RudiC For This Useful Post:
Stellaman1977 (1 Week Ago)
Sponsored Links
    #3  
Old Unix and Linux 2 Weeks Ago
Stellaman1977 Stellaman1977 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 19 October 2017, 10:38 AM EDT
Posts: 6
Thanks: 6
Thanked 0 Times in 0 Posts
Thanks- I'm using Solaris 9 which doesn't seem to recognize exit code option
Code:
-q

. Sorry- forgot to mention that. What I have up there is an attempt to simulate that.

The
Code:
!

will invert the true/false. I think that part is working actually. The cap and the missing closing parenthesis are typos here. Sorry again.

Long story short- I just want to be able to read metastat somehow, and if a drive is still resyncing, wait until its okay, then move to the next drive, and so on.
    #4  
Old Unix and Linux 2 Weeks Ago
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 20 October 2017, 11:16 AM EDT
Location: Amsterdam
Posts: 11,573
Thanks: 510
Thanked 3,355 Times in 2,959 Posts
Quote:
Originally Posted by Stellaman1977 View Post
Thanks- I'm using Solaris 9 which doesn't seem to recognize exit code option
Code:
-q

. [..]
Yes it does. You need to use /usr/xpg4/bin/grep for that..
The Following User Says Thank You to Scrutinizer For This Useful Post:
Stellaman1977 (1 Week Ago)
Sponsored Links
    #5  
Old Unix and Linux 1 Week Ago
Stellaman1977 Stellaman1977 is offline
Registered User
 
Join Date: Sep 2017
Last Activity: 19 October 2017, 10:38 AM EDT
Posts: 6
Thanks: 6
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Scrutinizer View Post
Yes it does. You need to use /usr/xpg4/bin/grep for that..
Thanks.. That works!
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can I reboot during a metadevice resync? the.gooch UNIX for Dummies Questions & Answers 8 08-30-2011 10:17 PM
Resync data on File system Mr.AIX AIX 6 04-25-2011 03:03 PM
trailing slash - resync command c00kie88 Shell Programming and Scripting 2 08-22-2008 10:29 AM
How long does AIX resync the time with another server victorcheung AIX 0 07-21-2008 06:54 AM
raidctl and resync when reboot csgonan UNIX for Dummies Questions & Answers 0 08-26-2007 05:34 PM



All times are GMT -4. The time now is 04:04 PM.