Here is another method to find a device number:
EnableADisk: /* Enable my 191 (A) disk */
'chccwdev -e 191 > /dev/null 2>&1'
If RC <> 0 Then Do
Call LogCmd 'Unable to enable 191 disk. RC from chccwdev =' RC
Return 2
End
'cat /proc/dasd/devices | grep "0.0.0191" | rxqueue'
Parse Pull rec
Adisk = '/dev/' || word(rec,7)
Call LogCmd "Adisk is:" Adisk
Return
Here are a couple of other options for reading a file:
/* Read a standard linux file */
'cat /etc/HOSTNAME | rxqueue'
Parse UPPER Pull rec
Another one:
GetDefaultConfig: /* Read the default config file from the 191 disk */
TargetParm = 'DEFAULT.CONFIG'
'cmsfslst -d' Adisk '| grep DEFAULT | grep CONFIG > /dev/null'
If RC <> 0 Then Do
Call LogCmd TargetParm "not found on 191 minidisk. Ignoring"
Return
End
'cmsfscat -a -d' Adisk TargetParm 'grep ^.| cut -f2 -d. | rxqueue'
Do Queued()
Parse Pull rec
/* Do something useful with the record */
Call LogCmd 'DefaultConfig:' rec
End
Return
George Shedlock Jr
AEGON Information Technology
AEGON USA
502-560-3541
-----Original Message-----
From: Linux on 390 Port [mailto:[email protected]] On Behalf Of Steffen
Maier
Sent: Wednesday, August 19, 2009 2:40 PM
To: [email protected]
Subject: Re: Sample REXX with cmsfs usage
On 08/18/2009 08:01 PM, Lionel Dyck wrote:
> I've been playing with rexx on z/linux along with trying to learn how to
> use the cmsfs toolset. Here is my first attempt that may be useful for
> others.
Nice one.
> #!/usr/bin/rexx
> /* REXX routine to read a cms file from the Linux Guest 191 Disk */
> /* Mount the users 191 disk */
> 'chccwdev -e 191'
>
> /* sleep 2 seconds to wait for the mount */
> call syssleep(2)
Waiting for the udev event queue to run empty is a safer way to wait for
the device to become online and available to Linux.
Depending on the version of your Linux you may use:
'udevadm settle'
or
'udevsettle'
> file = '/proc/dasd/devices'
>
> do forever
> line = strip(linein(file))
> if length(line) = 0 then leave
> parse value line with '0.0.'addr'(' x ' is 'disk .
> if addr = '0191' then leave
> end
Not sure, but this looks like an endless loop with busy waiting,
possibly eating unnecessary CPU cycles.
Chccwdev already loops (CPU friendly) to see if the device comes online
within some timeout and finally reports the outcome with an exit
errorlevel, that you may evaluate above to decide on continuation.
> 'chccwdev -d 191'
Here you could do "udevadm settle" again just to be sure that no events
caused by setting the device offline are pending when your script exits.
My 2ct,
Steffen
Linux on System z Development
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
----------------------------------------------------------------------
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
----------------------------------------------------------------------
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