Sponsored Content
Top Forums Shell Programming and Scripting To force a script to wait for another. Post 302249730 by Ne7o7 on Wednesday 22nd of October 2008 02:09:26 AM
Old 10-22-2008
Data To force a script to wait for another.

Hi All!

Here is the problem,

I'm trying to develop a script that can help me with the raid creation, but, till now, I have been dealing for more than a week and I still didn't achieve any satisfactory results. Smilie

Here is the code to execute:

# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2 --add /dev/sdb3
# mdadm --manage /dev/md3 --add /dev/sdb4

This wouldn't be difficult at all if this script was by itself but it comes after a partition disk operations and before I use grub for define the boot.

Here is how the structure of my global program looks like:

Global.sh
./Script for disk partition

./Mdadm script

./Grub script

The main problem is that the "grub script" must wait the "mdadm" one, otherwise it has no sense and it will return a mistake.

Because I'm a newbie in shell scripting I have been browsing around and I tried some of the things that look alike, but never I found a particular solution for this.

Here is the last one I tried

mdadm --manage /dev/md0 --add /dev/sdb1 &
wait $!
until [ $? == "0" ]
do
clear
cat /proc/mdstat #I want to know the status of the procedure at any time
sleep 1
done
......
...... #The same for the rest of cases


It doesn't works even with the first one of them, It looks that doesn't goes inside the "until" and if I push a couple of times "enter" I can reach the prompt Smilie.

mdadm --manage /dev/md0 --add /dev/sdb1 &
mdadm --manage /dev/md1 --add /dev/sdb2 &
mdadm --manage /dev/md2 --add /dev/sdb3 &
mdadm --manage /dev/md3 --add /dev/sdb4 &
wait $!

This also doesn't works in the way I need, I can reach the prompt and grub doesn't wait. Smilie

Let's summarize:
*I would like to make an script with this commands inside

# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2 --add /dev/sdb3
# mdadm --manage /dev/md3 --add /dev/sdb4

*The next script to execute (grub.sh) has to wait till all this processes are finished

Meanwhile the execution:
*In order to control the raid operations this command=> "cat /proc/mdstat" has to be execute with a little delay all the time
*The user cannot reach the prompt, thus is, the keyboard should be "blocked"

P.S.:I'm running Debian
P.S.2:Sorry for my English, I hope we can understand each other Smilie

Thanks for any collaboration Smilie

Last edited by Ne7o7; 10-22-2008 at 03:56 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

make my script wait

is there a way to make my script wait before doing something without using the "sleep _" command? (4 Replies)
Discussion started by: Blip
4 Replies

2. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. Shell Programming and Scripting

force to change password(shell script)

hi How can I force user to change of password by modifying the password expiry and the grace period so that the user has at least 1 week to login and change the password...... (3 Replies)
Discussion started by: tjay83
3 Replies

4. Shell Programming and Scripting

Script to wait until file is updated

Hello, I need to evaluate (under BASH) if the certain file has been updated or not. If the file still wasn't updated, script should wait. The script picks up the time stamp of the file using command OldTimestamp=$(date -r $MyDir/$MyFile), but I don't know how to code a waiting loop with new and... (6 Replies)
Discussion started by: sameucho
6 Replies

5. Shell Programming and Scripting

Wait function in a script

Hi everyone, I need some help to create a script. This script have to create a file once all the process inside are finish. Here how I want to do : #!/bin/ksh /home/oracle/save1.ksh & proc_id1=$! /home/oracle/save2.ksh & proc_id2=$! /home/oracle/save3.ksh & proc_id3=$! ... (4 Replies)
Discussion started by: remfleyf
4 Replies

6. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

7. Shell Programming and Scripting

Script to force close sheet opened by someone else

Was wondering what script to run as root that will take as input a filename (full path) that is opened by someone else and force whoever has it opened to close it? Or maybe there is an existing command to do this? Thanks Edit: Meant to say file not sheet, too much Excel... (2 Replies)
Discussion started by: stevensw
2 Replies

8. Shell Programming and Scripting

Script should wait for password while doing scp

Hi team, need help on this :- trying to scp a file from A ( it could any server among hundreds not one) server to B server ( fixed ) . The script runs in a third server CFGEngine server. a. we dont use static password ( its pin + rsa token) so , "here documents" kind of thing is not... (3 Replies)
Discussion started by: gauravsharma29
3 Replies

9. Shell Programming and Scripting

Script using Wait

Hi, written a script which uses wait as follows Main.sh #!/usr/bin/ksh nohup scrpit1 1 & pid_1=$! nohup scrpit1 2 & pid_2=$! wait $pid_1 wait $pid_2 nohup scrpit1 3 & pid_1=$! nohup scrpit1 4 & (1 Reply)
Discussion started by: krux_rap
1 Replies

10. UNIX for Dummies Questions & Answers

Script to run another script with wait time

I want to create a script which calls another script with certain interval. Script "A" should call script "B" every 60 seconds. Script "A" should also be able to call other scripts such as "C", "D", etc. at an interval of 60, 120, 180 seconds respectively. Basically script A should take two... (1 Reply)
Discussion started by: Vee
1 Replies
SCSI_START(8)							     SG3_UTILS							     SCSI_START(8)

NAME
scsi_start - start one or more SCSI disks SYNOPSIS
scsi_start [--help] [--verbose] [--wait] DEVICE [DEVICE]* DESCRIPTION
This Bourne shell script calls the sg_start utility on each given DEVICE. The purpose is to spin up (start) each given DEVICE. OPTIONS
Arguments to long options are mandatory for short options as well. -h, --help print out the usage message then exit. -v, --verbose increase level or verbosity. -w, --wait wait for the spin up (start) on each given DEVICE to complete. The default action is to do each start in immediate mode. NOTES
If a large number of disks are spun up at the same time (i.e. without the --wait option) then the power supply may be overloaded. EXIT STATUS
The exit status of this script is 0 when it is successful. Otherwise the exit status is that of the last sg_start utility called. See the sg3_utils(8) man page. AUTHORS
Written by D. Gilbert COPYRIGHT
Copyright (C) 2009 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_start (sg3_utils) sg3_utils-1.28 August 2009 SCSI_START(8)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy