Chris Young and I came up with this bash function to help in situations
like this:
#+--------
function wait_for_device
# Sleep until a certain file exists
# Arg1: The path of the file to sleep on.
#+--------
{
device=$1
for t in $(seq 1 20)
do
[ -e $device ] && return 0
sleep 1
done
return 1
}
Then inside of the same script, we'd call something like:
wait_for_device /dev/dasdc1
(for example)
If you're trying this on RHEL, I recommend the latest update (4.6 or
5.1). There are udev fixes that make device creation instantaneous,
making this function unnecessary.
-Brad
On Wed, 2007-12-12 at 11:57 -0500, Michael MacIsaac wrote:
> Robert,
>
> I list the files with a file type of PARM-S10 on a Linux user ID's 191
> disk (which is actually a LINK not an MDISK) with a function named foo:
> # ./foo
> Setting device 0.0.0191 offline
> Done
> Setting device 0.0.0191 online
> Done
> LINUX116 PARM-S10 D1 V 73 9 1 11/20/2007 9:42:35
> LINUX117 PARM-S10 D1 V 73 9 1 11/21/2007 7:36:19
> LINUX118 PARM-S10 D1 V 73 9 1 11/21/2007
> 14:49:46
> LINUX119 PARM-S10 D1 V 73 9 1 11/21/2007
> 14:50:01
> SLES10S1 PARM-S10 D1 V 73 9 1 11/20/2007 9:42:44
> LINUX125 PARM-S10 D1 V 73 9 1 12/10/2007
> 14:08:52
>
> Then I go to a 3270 session and create a new file on the 191 disk with a
> file name of LINUX126 and run foo again.
> # ./foo
> Setting device 0.0.0191 offline
> Done
> Setting device 0.0.0191 online
> Done
> LINUX116 PARM-S10 D1 V 73 9 1 11/20/2007 9:42:35
> LINUX117 PARM-S10 D1 V 73 9 1 11/21/2007 7:36:19
> LINUX118 PARM-S10 D1 V 73 9 1 11/21/2007
> 14:49:46
> LINUX119 PARM-S10 D1 V 73 9 1 11/21/2007
> 14:50:01
> LINUX125 PARM-S10 D1 V 73 9 1 12/10/2007
> 14:08:52
> SLES10S1 PARM-S10 D1 V 73 9 1 11/20/2007 9:42:44
> LINUX126 PARM-S10 D1 V 73 9 1 12/12/2007
> 11:44:45
>
> I see that LINUX126 PARM-S10 is shown. So here is foo:
> # cat foo
> #!/bin/bash
> chccwdev -d 191
> chccwdev -e 191
> rc=$?
> sleep 1 # what is the better function here?
> if [ $rc != 0 ]; then # unable to enable 191 disk
> echo "Error: unable to enable 191, rc from chccwdev = $rc"
> exit
> fi
> CMSdisk=$(lsdasd | grep 0191 | awk '{ print $7 }')
> cmsfslst -d /dev/$CMSdisk | grep PARM-S10
> rc=$?
> if [ $rc != 0 ]; then
> echo "Error: cmsfslst rc = $rc"
> exit
> fi
>
> I recall seeing similar "unpredictable results" with cmsfslst as you
> allude to, and then added the "sleep 1" call which seemed to work around
> the problem.
>
> Somebody posted that there is a better command than sleep designed to wait
> until the "chccwdev -e" took effect. Anybody remember that call?
>
> I guess another question is "Will there be a non-asynchronous chccwdev
> command/flag?" (The z/VM folks did a nice job of that for FLASHCOPY in VM
> 5.3!).
>
> Hope this helps.
>
> "Mike MacIsaac" <[EMAIL PROTECTED]> (845) 433-7061
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
> http://www.marist.edu/htbin/wlvindex?LINUX-390
--
Brad Hinson <[EMAIL PROTECTED]>
Sr. Support Engineer Lead, System z
Red Hat, Inc.
(919) 754-4198
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390