Re: Automatic checkin on a 3584?
Thanks for all the comments, suggestions, ideas, and code examples. They were very invaluable! I also found expect to be an interesting approach that I hadn't considered, but makes sense. Looks like I'm on the right track now; thanks again! -Dan
Re: Automatic checkin on a 3584?
Here is a script that I use to remove media. It has to do a reply for each tape. The section on looking for at "q req" and responding should do about what you want. The functions at the top are from an old script and not used in this one. I am short on time so I did not clean it up for you. Sorry. -- Phillip Ford Senior Software Specialist Corporate Computer Center Schering-Plough Corp. (901) 320-4462 (901) 320-4856 FAX [EMAIL PROTECTED] * This message and any attachments are solely for the intended recipient. If you are not the intended recipient, disclosure, copying, use or distribution of the information included in this message is prohibited -- Please immediately and permanently delete. #!/usr/bin/sh #set -x # file /var/operlib/adsm/remove_drm # sub to check process to see if it is still running check_process() { process=`dsmadmc -id=$usr -pass=$pw q proc $job1 | grep -c 'MOVE DRMEDIA'` if [ $debug -gt 0 ]; then echo process is $process fi if [ $debug -gt 1 ]; then process=1 echo resetting process to $process fi } # sub to get request number get_request() { request=0 req="" dsmadmc -id=$usr -pass=$pw q request | grep 'Remove 3570' | read x1 req x3 x4 if [ $debug -gt 0 ]; then echo req is $req fi if [ $debug -gt 1 ]; then req="026:" echo resetting req to $req fi if [ "X${req}" != "X" ]; then len=`expr length $req` len=`expr $len - 1` req=`expr substr $req 1 $len` request=`expr $req + 0` fi if [ $debug -gt 0 ]; then echo request is $request fi if [ $debug -gt 1 ]; then request=1 echo resetting request to $request fi } # debug - 0 no debug 1-print 2-simulate debug=0 lib=lib0 if [ $debug -gt 0 ]; then echo debug is on and set to $debug echo library to use is $lib fi cat /etc/adsm/adsm | read usr pw CMD="dsmadmc -id=$usr -password=$pw" CMD1="dsmadmc -id=$usr -password=$pw -comma " $CMD "move drm * wherestate=mountable tostate=vault remove=untileefull" > /tmp/checkout_log if [ $? -eq 0 ]; then RETRY=0 sleep 30 while true do $CMD q request > /tmp/checkout_ask grep ANR8322I /tmp/checkout_ask > /dev/null if [ $? -eq 0 ]; then RETRY=0 grep ANR8322I /tmp/checkout_ask |grep "Remove LTO volume" |awk '{print $2}' > /tmp/checkout_reply COMMAND=`sed s/://g /tmp/checkout_reply` $CMD "reply $COMMAND" > /dev/null rm /tmp/checkout_* sleep 30 else # now check if move drm is still running - if not quit i=`$CMD1 "q proc " | /var/operlib/adsm/cleanhdrs | grep -c "MOVE DRMEDIA"` if [ "$i" = "0" ]; then rm /tmp/checkout_* break fi rm /tmp/checkout_* sleep 30 # if (( $RETRY<30 )) ; then # RETRY=`expr $RETRY + 1` # else # break # fi fi done fi
Re: Automatic checkin on a 3584?
Dan -- I've been running a perl script on AIX to do this for several years (STK 9710 first, then the 3584). My script tails the TSM log and works in this order: 1. 'checkin libv search=bulk stat=private checklabel=barcode' 2. look for the ANR8373I message, peel off the reply number, and issue the 'REPLY #' 3. look for the ANR8430I message, peel off the volume number, and update the volume to access readwrite 4. look for the ANR8431I and exit By checking all volumes in as private and then updating to read/write the corner cases go away; expired tapes go scratch, old database backups stay private until deleted, and (big one) No Thinking Is Required. And by using perl and the File::Tail module, there's no requirement for 'sleep' and no timing issues if TSM goes off to do tape dismounts right after you fire up the script. The process uses Owen Crow's Adsm.pm perl module from several years ago -- let me know if you want to take a swack at what I've got. Tom Kauffman NIBCO, Inc -Original Message- From: Dan Foster [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 3:24 AM To: [EMAIL PROTECTED] Subject: Automatic checkin on a 3584? Howdy - I seem to be having some sort of timing issues with the checkin process via an automated script. The procedure: 1. Fill the I/O station(s) with brought back tapes to be checkin'd 2. Issue a 'checkin libvol search=bulk status=scratch checklabel=barcode' 3. Wait a bit for a request to appear in the request queue 4. Issue a reply corresponding to what appears in 'q req' 5. Wait a bit for the whole checkin process to finish in search mode 6. Issue a 'checkin libvol search=bulk status=private checklabel=barcode' 7. Wait a bit for a request to appear in the request queue 8. Issue a reply corresponding to what appears in 'q req' Manually, works great. My script parses all data just fine using dsmadmc in batch mode (with -id= -pass=...) and the command syntax is correct -- I know because it works fine by hand. I'm a little stuck in getting the exact timing *just right* for the delays as well as the best way to construct a while loop logic to get the timing right. It just runs through it so fast that it exits before it's got a chance to answer both requests. Detecting certain corner cases seems a little interesting when you throw in vagaries of timing, also. Alas, "cheating" by direct loading and using search=yes to avoid the requests isn't an option for the weekly tape swaps. ;) Does anyone happen to have a similiar script fragment or even just suggestions on how to construct the while loop 'just so'? :) Anything would be much appreciated! (I'm trying to make the limited human interaction with tapes reasonably bulletproof without requiring them to manually wade through TSM - reduces chances of errors and not all personnel are skilled.) -Dan
Re: Automatic checkin on a 3584?
Hi I'm using the Expect tool (available as an RPM for AIX 5L) to achieve pretty much what you're trying to do. Expect allows you to automate responses to interactive programs. For example, here is the section of my check-in shell script that waits for the "checkin" process to complete :- - # Check for any tapes in I/O station that could not be checked in print "* Please wait whilst tapes are being checked in.\n" /usr/bin/expect <${PID}_3 2>/dev/null set timeout 10 stty -echo log_user 0 spawn /usr/bin/dsmadmc expect { -re "Enter your user id:.*" {send "${DSMUSER}\r"} timeout {send_user "\nERROR: Expect timeout.\n";exit } } expect { -re "Enter your password:.*" {send "${DSMPASSWD}\r"} timeout {send_user "\nERROR: Expect timeout.\n";exit } } expect { "tsm: HPCXTSM>" {send "query proc ${PROC}\r"} timeout {send_user "\nERROR: Expect timeout.\n";exit } } while 1 { sleep 2 expect { -re "ANS8001I Return code 11.*" {send "q actlog begint=${TIME} search=ANR8443E\r";break} "tsm: HPCXTSM>" {send "query proc ${PROC}\r"} timeout {send_user "\nERROR: Expect timeout.\n";exit } } } log_user 1 while 1 { expect { "more..." {send "\r"} "tsm: HPCXTSM>" {send "quit\r"} timeout {send_user "\nERROR: Expect timeout.\n";exit } } } expect eof EOF Hope this is of some help. Regards Ian -Original Message- From: Dan Foster [mailto:[EMAIL PROTECTED] Sent: 03 March 2003 08:24 To: [EMAIL PROTECTED] Subject: Automatic checkin on a 3584? Howdy - I seem to be having some sort of timing issues with the checkin process via an automated script. The procedure: 1. Fill the I/O station(s) with brought back tapes to be checkin'd 2. Issue a 'checkin libvol search=bulk status=scratch checklabel=barcode' 3. Wait a bit for a request to appear in the request queue 4. Issue a reply corresponding to what appears in 'q req' 5. Wait a bit for the whole checkin process to finish in search mode 6. Issue a 'checkin libvol search=bulk status=private checklabel=barcode' 7. Wait a bit for a request to appear in the request queue 8. Issue a reply corresponding to what appears in 'q req' Manually, works great. My script parses all data just fine using dsmadmc in batch mode (with -id= -pass=...) and the command syntax is correct -- I know because it works fine by hand. I'm a little stuck in getting the exact timing *just right* for the delays as well as the best way to construct a while loop logic to get the timing right. It just runs through it so fast that it exits before it's got a chance to answer both requests. Detecting certain corner cases seems a little interesting when you throw in vagaries of timing, also. Alas, "cheating" by direct loading and using search=yes to avoid the requests isn't an option for the weekly tape swaps. ;) Does anyone happen to have a similiar script fragment or even just suggestions on how to construct the while loop 'just so'? :) Anything would be much appreciated! (I'm trying to make the limited human interaction with tapes reasonably bulletproof without requiring them to manually wade through TSM - reduces chances of errors and not all personnel are skilled.) -Dan
Re: Automatic checkin on a 3584?
Hello, Here is what I use on AIX4.3.3 to make automatic checkin every morning, it is done in ksh. #!/bin/ksh dsmadmc -id=admin -pa=admin "checkin libv l20 search=bulk checkl=barcode status=private" sleep 15 REQNO=$(dsmadmc -id=admin -pa=admin "q req"|grep ANR8373I| awk '{print $2}'|tr -d ':') dsmadmc -id=admin -pa=admin "reply $REQNO" I hope it will help you. I don't understand why you have to issue two checkin, one with status=private and the other with status=scratch, but I am not sure I fully understood this option and anyway, I only need the private status. But if you need to issue both, I guess you can let TSM a long time to finish the first checkin, something like 10 minutes. Usually, checkin of new volumes is not that urgent. Etienne GUILLAUMONT e-mail : [EMAIL PROTECTED] RGB Technologie Parc d'Innovation, Bâtiment PYTHAGORE 11 Rue Jean SAPIDUS 67400 ILLKIRCH Tél : 03 90 40 60 60 Fax : 03 90 40 60 61 Halvorsen GeirrTo: [EMAIL PROTECTED] Gulbrand cc: <[EMAIL PROTECTED]Subject: Re: Automatic checkin on a 3584? .COM> Sent by: "ADSM: Dist Stor Manager" <[EMAIL PROTECTED] RIST.EDU> 03/03/2003 10:06 Please respond to "ADSM: Dist Stor Manager" Hi Dan, I'm just about to do something like you, and I just have the following idea. >From experience, a 10 sec. wait is enough for the request to be generated in tsm, so either a wait statement that waits 10 seconds, or creating a for-loop that runs for about 10 seconds, and then continue. Another idea, would be to (repeatedly) issue command q req, and on the right RETURN code (0), continue the script. I can't remember how to catch the return code through dsmadmc, but I'm sure someone else on the list can tell us. (or you could use the command with the outfile option, then parse the file for the info wanted. My best choice would be to use a wait, that waits long enough for the request to be created, just because it makes the script shorter (usually). Rgds. Geirr G. Halvorsen -Original Message- From: Dan Foster [mailto:[EMAIL PROTECTED] Sent: 3. marts 2003 09:24 To: [EMA
Re: Automatic checkin on a 3584?
Hi Dan, I'm just about to do something like you, and I just have the following idea. >From experience, a 10 sec. wait is enough for the request to be generated in tsm, so either a wait statement that waits 10 seconds, or creating a for-loop that runs for about 10 seconds, and then continue. Another idea, would be to (repeatedly) issue command q req, and on the right RETURN code (0), continue the script. I can't remember how to catch the return code through dsmadmc, but I'm sure someone else on the list can tell us. (or you could use the command with the outfile option, then parse the file for the info wanted. My best choice would be to use a wait, that waits long enough for the request to be created, just because it makes the script shorter (usually). Rgds. Geirr G. Halvorsen -Original Message- From: Dan Foster [mailto:[EMAIL PROTECTED] Sent: 3. marts 2003 09:24 To: [EMAIL PROTECTED] Subject: Automatic checkin on a 3584? Howdy - I seem to be having some sort of timing issues with the checkin process via an automated script. The procedure: 1. Fill the I/O station(s) with brought back tapes to be checkin'd 2. Issue a 'checkin libvol search=bulk status=scratch checklabel=barcode' 3. Wait a bit for a request to appear in the request queue 4. Issue a reply corresponding to what appears in 'q req' 5. Wait a bit for the whole checkin process to finish in search mode 6. Issue a 'checkin libvol search=bulk status=private checklabel=barcode' 7. Wait a bit for a request to appear in the request queue 8. Issue a reply corresponding to what appears in 'q req' Manually, works great. My script parses all data just fine using dsmadmc in batch mode (with -id= -pass=...) and the command syntax is correct -- I know because it works fine by hand. I'm a little stuck in getting the exact timing *just right* for the delays as well as the best way to construct a while loop logic to get the timing right. It just runs through it so fast that it exits before it's got a chance to answer both requests. Detecting certain corner cases seems a little interesting when you throw in vagaries of timing, also. Alas, "cheating" by direct loading and using search=yes to avoid the requests isn't an option for the weekly tape swaps. ;) Does anyone happen to have a similiar script fragment or even just suggestions on how to construct the while loop 'just so'? :) Anything would be much appreciated! (I'm trying to make the limited human interaction with tapes reasonably bulletproof without requiring them to manually wade through TSM - reduces chances of errors and not all personnel are skilled.) -Dan
Re: Automatic checkin on a 3584?
Hot Diggety! GUILLAUMONT Etienne was rumored to have written: > > You didn't say in what type of OS you where. If it is unix, no problem, you Oops! I'm normally good about that. Server is AIX 5.1 on pSeries 660 model 6H1 server. I do have some sleeps, but it's still running too fast or not exactly right. -Dan
Re: Automatic checkin on a 3584?
Hello, You didn't say in what type of OS you where. If it is unix, no problem, you just have to add a sleep command. If you have a unix box within you clients, you can also install dsmadmc on it and make the script on unix which is far better for shell scripts and automations than windows. The other way is not to use a timing but to do exactly what you do manually : check for example the process before continuing. Etienne GUILLAUMONT e-mail : [EMAIL PROTECTED] RGB Technologie Parc d'Innovation, Bâtiment PYTHAGORE 11 Rue Jean SAPIDUS 67400 ILLKIRCH Tél : 03 90 40 60 60 Fax : 03 90 40 60 61 Dan Foster <[EMAIL PROTECTED]To: [EMAIL PROTECTED] >cc: Sent by: Subject: Automatic checkin on a 3584? "ADSM: Dist Stor Manager" <[EMAIL PROTECTED] RIST.EDU> 03/03/2003 09:23 Please respond to "ADSM: Dist Stor Manager" Howdy - I seem to be having some sort of timing issues with the checkin process via an automated script. The procedure: 1. Fill the I/O station(s) with brought back tapes to be checkin'd 2. Issue a 'checkin libvol search=bulk status=scratch checklabel=barcode' 3. Wait a bit for a request to appear in the request queue 4. Issue a reply corresponding to what appears in 'q req' 5. Wait a bit for the whole checkin process to finish in search mode 6. Issue a 'checkin libvol search=bulk status=private checklabel=barcode' 7. Wait a bit for a request to appear in the request queue 8. Issue a reply corresponding to what appears in 'q req' Manually, works great. My script parses all data just fine using dsmadmc in batch mode (with -id= -pass=...) and the command syntax is correct -- I know because it works fine by hand. I'm a little stuck in getting the exact timing *just right* for the delays as well as the best way to construct a while loop logic to get the timing right. It just runs through it so fast that it exits before it's got a chance to answer both requests. Detecting certain corner cases seems a little interesting when you throw in vagaries of timing, also. Alas, "cheating" by direct loading and using search=yes to avoid the requests isn't an option for the weekly tape swaps. ;) Does anyone happen to have a similiar script fragment or even just suggestions on how to construct the while loop 'just so'? :) Anything would be much appreciated! (I'm trying to make the limited human int