; lb2600 - Serials: titles, PO#s, details, by fund and dept - WinBatch script ; this WinBatch file starts at a certain time, ftp's the SQL report file from ; Voyager, brings it into Word, formats it, and prints it in the Library's ; Serials printer ; should run all the time ; starting this script: ; start after main loop checking time if today is the day the report is to be ; printed and it has already been printed ; else can start any time and any day ; Word settings: ; 7pt Monospac 821DL, landscape, ; .5" margins ; print on first floor Serials printer ;*** CONSTANTS unixpath = "/usr/local/rpt/" pcpath = "c:\librpts\" rptid = "lb2600" rptext = ".rpt" pwfilename = "c:\librpts\batchpw.psi" pwfile = fileopen(pwfilename, "read") pw = fileread(pwfile) fileclose(pwfile) pwstr = strcat(pw, "~") ;*** BUILD COMPLETE UNIX AND PC FILENAMES unixfile = strcat(unixpath, rptid, rptext) ;message("",unixfile) pcfile = strcat(pcpath, rptid, rptext) ;message("",pcfile) ftpfile = strcat("c:\program files\winbatch\batch files\", rptid, "ftp.wbt") ;*** MAIN LOOP STRUCTURE ;********* :starthere ;********* timenow = strsub(timeymdhms(), 12, 8) modaynum = strsub(timeymdhms(), 9, 2) if (modaynum == "02") || (modaynum == "16") then if (timenow >= "10:15:00") && (timenow <= "10:29:00") then ftppwstr = strcat('sendkeysto("~ftp","', pwstr, '")') ftpgetstr = strcat('sendkeysto("~ftp",', '"get ', unixfile, ' ', pcfile, '~~")') hftp = fileopen(ftpfile, "write") filewrite(hftp, 'run ("c:\winnt\system32\ftp.exe","")') ; filewrite(hftp, 'timedelay(10)') filewrite(hftp, 'winwaitexist("~ftp", 20)') filewrite(hftp, 'sendkeysto("~ftp","open voyager.library.wmich.edu~")') filewrite(hftp, 'sendkeysto("~ftp","zimmer~")') filewrite(hftp, ftppwstr) filewrite(hftp, 'sendkeysto("~ftp","ascii~")') filewrite(hftp, ftpgetstr) filewrite(hftp, 'sendkeysto("~ftp","bye~~")') fileclose(hftp) run(ftpfile,"") timedelay(30) if fileexist(pcfile) then ; ***format and print it run ("c:\program files\microsoft office\office\winword.exe", "") ; next line to make sure Word is active window??!!? sendkeysto("~Microsoft Word", "{DOWN}") sendkeysto("~Microsoft Word", "!f{DOWN}{ENTER}") sendkeysto("~Open", "%pcfile%{ENTER}") ; handle and remove file conversion window sendkey("{UP 4}{TAB}{ENTER}") ; delete leading formfeed sendkey("{DEL}") ; set document size and orientation sendkey("!f{TAB 8}{ENTER}!s!c!m!t.5!b.5!f.5!h.5{TAB 8}{ENTER}") ; set font and font size sendkey("!e{TAB 8}{ENTER}!o{ENTER}") sendkey("Monospac821 DL{TAB}{TAB}7") sendkey("!k!k!p!p!w!w!m!m!h!h{TAB 2}{ENTER}") timedelay(5) ; now send to printer ; this sendkey string may change whenever the ; available printer pool changes, ; or if the default printer is changed ; sendkey ("^p{TAB 7}!n{TAB 9}{ENTER}") ; for local TESTING sendkey("^p!n{DOWN 2}{TAB 2}{ENTER}") ; wait for doc to print timedelay(60) ; now close Word sendkey("!f{UP}{ENTER}!n") ; wait until 0823 tomorrow so can exit processing loop now = timeymdhms() tomorrow_at_823 = timeadd(strcat(strsub(now,1,11),"00:00:00"), "0000:00:01:08:23:00") timewait(tomorrow_at_823) exitvalue = 1 ; else> hook for email notification: failure, .rpt file not found endif else ; wait 10 minutes and try again timedelay(600) exitvalue = 1 endif else ; not desired day, so wait a day ; wait until 0823 tomorrow now = timeymdhms() tomorrow_at_823 = timeadd(strcat(strsub(now,1,11),"00:00:00"), "0000:00:01:08:23:00") timewait(tomorrow_at_823) exitvalue = 1 endif if exitvalue == 1 then goto starthere ; this would be a good location to hook into failure notification via email errmsg = strcat("Contact programmer.%@crlf%Script for ", rptid, rptext, " exited loop.") message("ERROR", errmsg); exit