ADSM-L

Re: Automatic checkin on a 3584?

2003-03-03 09:16:10
Subject: Re: Automatic checkin on a 3584?
From: "Shore, IM (Ian)" <I.M.Shore AT DL.AC DOT UK>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Mon, 3 Mar 2003 13:57:13 -0000
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 <<EOF >${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:dsf AT GBLX DOT NET]
Sent: 03 March 2003 08:24
To: ADSM-L AT VM.MARIST DOT EDU
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 <library> 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 <library> 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

<Prev in Thread] Current Thread [Next in Thread>