Re: Scripting question -- readstatus
I used this: \([1-9][0-9]*\) instead of: \(.\) It will give any number >= 1. On Thu, 15 Feb 2001, Joseph Del Corso wrote: > First I'd like to thank everyone for their help with scripts, > I recieved quite a few that were all excellent resources for creating > my own. > > I have a tape rack that holds 35 tapes, and an robotic arm tape changer > that picks up the tapes and sticks them in the tape drive(s). > > I modified chg-zd-mtx, specifically the readstatus line, to read like: > > usedslot=`$MTX -f /dev/sg3 status | sed -n 's/Data Transfer Element > 0:Empty/-1/p;s/Data Transfer Element 0:Full (Storage Element > \(.\) Loaded):VolumeTag = DNR\(.\)\(.\)\(.\)/\1/p'` > > > This worked great!! For the first 9 tapes... and I realized why. > In the previous line the number after Storage Element is read into > ?variable? \(.\) <- This represents one number. In order to go > higher than 9 though I had to add a second \(.\) and a \2 so that it looks > like: > > usedslot=`$MTX -f /dev/sg3 status | sed -n 's/Data Transfer Element > 0:Empty/-1/p;s/Data Transfer Element 0:Full (Storage Element > \(.\)\(.\) Loaded):VolumeTag = DNR\(.\)\(.\)\(.\)/\1\2/p'` > > My question is, is there a more elegant way (without scraping the whole > script and trying a completely new one -- leading to more headaches and > troubleshooting) to do what I'm trying to do? (i.e.-- read higher than one > digit numbers, and possibly two digit -- though honestly I'm not at that > point yet) > > As soon as I try and use this script to do any amcheck or dumping to the > first 9 tapes, I'll have to revert everything back. > > Hope I explained this clearly enough, and that someone out there with more > intelligence than I in scripting can help out. > > Joe -- Jason Hollinden SMG Systems Admin
AW: Scripting question -- readstatus
-Ursprüngliche Nachricht- Von: Joseph Del Corso [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 15. Februar 2001 18:36 An: [EMAIL PROTECTED] Betreff: Scripting question -- readstatus Hi joseph, try the following quick-hack: instead of using \(.\)\(.\) in the sed-command, try using \([0-9]*\)... this regexp matches ANY number of digits, so even more than 99 tapes should be no problem, :-)... in the substitution, you can then still use your first script with only a \1. regards, Harald
Scripting question -- readstatus
First I'd like to thank everyone for their help with scripts, I recieved quite a few that were all excellent resources for creating my own. I have a tape rack that holds 35 tapes, and an robotic arm tape changer that picks up the tapes and sticks them in the tape drive(s). I modified chg-zd-mtx, specifically the readstatus line, to read like: usedslot=`$MTX -f /dev/sg3 status | sed -n 's/Data Transfer Element 0:Empty/-1/p;s/Data Transfer Element 0:Full (Storage Element \(.\) Loaded):VolumeTag = DNR\(.\)\(.\)\(.\)/\1/p'` This worked great!! For the first 9 tapes... and I realized why. In the previous line the number after Storage Element is read into ?variable? \(.\) <- This represents one number. In order to go higher than 9 though I had to add a second \(.\) and a \2 so that it looks like: usedslot=`$MTX -f /dev/sg3 status | sed -n 's/Data Transfer Element 0:Empty/-1/p;s/Data Transfer Element 0:Full (Storage Element \(.\)\(.\) Loaded):VolumeTag = DNR\(.\)\(.\)\(.\)/\1\2/p'` My question is, is there a more elegant way (without scraping the whole script and trying a completely new one -- leading to more headaches and troubleshooting) to do what I'm trying to do? (i.e.-- read higher than one digit numbers, and possibly two digit -- though honestly I'm not at that point yet) As soon as I try and use this script to do any amcheck or dumping to the first 9 tapes, I'll have to revert everything back. Hope I explained this clearly enough, and that someone out there with more intelligence than I in scripting can help out. Joe