Date: Thu, 5 Jan 2006 22:09:03 +1030 From: Malcolm Kay <malcolm.kay@internode.on.net> To: user <user@dhp.com> Cc: freebsd-questions@freebsd.org Subject: Re: how can I find out which md device I just used ? (mdconfig) Message-ID: <200601052209.03310.malcolm.kay@internode.on.net> In-Reply-To: <Pine.LNX.4.21.0601050122090.8684-100000@shell.dhp.com> References: <Pine.LNX.4.21.0601050122090.8684-100000@shell.dhp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 5 Jan 2006 04:54 pm, user wrote: > On Thu, 5 Jan 2006, Malcolm Kay wrote: > > On my system (5.4) mdconfig reports the created device to > > stdout: So: > > memdevice=`mdconfig -a -t malloc -s10M` > > sets the device name in $memdevice. > > Thank you very much - I have just verified that this works the > same way on FreeBSD 6.0. I appreciate your help. > > I am curious, I am doing two things at one here - setting the > variable _and_ configging the md device. What is the best > way, in a shell script, to also test to make sure that the > device configured properly ? > > If the device does not configure properly, all I see is that I > get a empty variable ... would it be appropriate to `text -z` > that variable to see if it is zero ? Or is there a better way > to approach that ? > I imagine that like most unix utilities it returns status 0 on success and non-zero on failure. So imediately after: memdevice=`mdconfig -a -t malloc -s10M` Use: if [ $? -ne 0 ] then echo "mdconfig failed" exit 1 fi Malcolm Kay > Basically I do not want to act unless I am sure that the > mdconfig actually happened, and there really is a variable > defined...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601052209.03310.malcolm.kay>