Velocity Scheduler

2.3.3 Example 3
Example 3: Batch script that calls a Perl or Python script

REM set CCS required keywords
REM CCS account = userid
REM CCS type = batch
REM CCS nodes = 1
REM CCS minutes = 10
REM CCS requirements = 1@development

REM Run perl script, preferring Active State Perl over cygwin's -
REM Must specify full path if userlogin.bat runs setup_cygwin.bat

set PERLEXE=C:\Perl\bin\perl
set SCRIPTDIR=\\tc.cornell.edu\tc\Users\userid\jobstuff

%PERLEXE% %SCRIPTDIR%\runjob.pl

REM Could equally well invoke C:\Python22\python %SCRIPTDIR%\runjob.py

REM release resources
ccrelease

Click on the script names above to see examples of runtime decision-making and error handling in Python or Perl.

The advantage of writing instructions in Perl or Python versus the Windows command shell language is that the former are more robust for programming. For example, an if-then-else construct using Windows commands might look like this:

if 1 EQU 1 (echo yes, they are equal) else (echo so confused & del C:\WINNT\system32\*.*)

This line, in addition to being ugly, is rather touchy: it may be split onto multiple command lines only before ")", after "(", or in place of "&". Furthermore, Perl and Python have better facilities for error handling—by using the "|| die" and try-except constructs, respectively—and their scripts are portable among various platforms. On the other hand, results are usually more predictable when one uses the native OS language.

Perl or Python are also better suited to create a "babysitter" script that runs continuously on a login node. Such a script would periodically issue CCS and/or Windows commands in order to monitor job progress and even submit new batch jobs on your behalf! (Such tricks require advanced scripting techniques.)