Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl/ClearCase Programming With an emphasis on UNIX/Windows interoperation David Boyce BMRCCUG 9/25/2001.

Similar presentations

Presentation on theme: "Perl/ClearCase Programming With an emphasis on UNIX/Windows interoperation David Boyce BMRCCUG 9/25/2001."— Presentation transcript:

1 Perl/ClearCase Programming With an emphasis on UNIX/Windows interoperation David Boyce BMRCCUG 9/25/2001

2 General Notes Me Focus: Scripting vs Programming Portability vs Interoperability Perl vs Java (philosophy)

3 A Co-Operating Win32 Perl ClearCase bundled perl (ccperl) Local-only WIN32 build Local with network modules Networked standard build Networked ActiveState build

4 Sharing modules Make use of SMB symlink translation Must be on UNIX/Samba/TAS/NAS Some SMB’s require symlink switch Even WIN32 binary modules work Share /usr/local/bin (\\server\ulb)\\server\ulb or /usr/local (\\server\local).\\server\local All maintenance from UNIX.

5 Sharing and executing scripts Choices: executing scripts on Windows Register extension Use pl2bat Use a redirector: @echo off \\server\perl\bin\perl \\server\ulb\whence %* Local.bat, remote/shared perl script (ulb) Use perl’s bin directory UNC path entries must be user and at end

6 Trigger Definition % ct lstype -l trtype:mkelem_post trigger type "mkelem_post" 02-Aug-99.18:35:01 by [VOB Admin] (vobadm.ccusers@sparc5) owner: vobadm group: ccusers all element trigger post-operation mkelem action: -execunix /usr/local/bin/perl /data/ccase/triggers/mkelem_post.tgr action: -execwin perl //ultra10/triggers/mkelem_post.tgr excluded users: vobadm My triggers are at

7 Interop Tips and Tricks use constant MSWIN => $^O =~ /MSWin32|Windows_NT/i; Quoting: make use of qq() and q() Especially in –e scripts No single quote (‘) in cmd.exe Remember: 2>&1 works on Windows -e “foo@@/main/0” Useful for testing dynamic-vs-snapshot Follow with ct desc for snapshot support

8 Interop Tips and Tricks (cont) Make a DNS alias “usr” for the fileserver Enables e.g. “//usr/local/bin” anywhere Useful for includes in cspecs etc. Use the notify command for email (4.0) Beware of PERL5LIB et al (CC bug) Use binmode on all binary files Cleartool returns native version paths

9 Interop Tips and Tricks (cont) Use s%\\%/%g if MSWIN; File::Spec 0.82 (abstract pathnames) File::Spec->rel2abs($path); # native fmt File::Spec::Unix->rel2abs($path); # force Unix fmt my $nul = MSWIN ? ‘NUL’ : ‘/dev/null’; system(“cmd >$nul 2>&1”);

10 Interop: system() and exec() The documentation lies! system() always uses a shell exec() always exits Perl 5.6.0 emulates fork but not exec emulation: exit(system(“cmd”)!=0)); Best: use ClearCase::Argv for complex/long-running programs

11 My Perl Modules ClearCase::ClearPrompt ClearCase::Wrapper ClearCase::SyncTree ClearCase::CRDB Env::Path IPC::ClearTool ClearCase::Argv

12 ClearCase::ClearPrompt Handles temp files automatically Capable of asynchronous operation Handles trigger series automatically Captures/emails error msgs (*CC 4.2) use ClearCase::ClearPrompt qw(clearprompt +TRIGGERSERIES +CAPTURE=vobadm); clearprompt(‘proceed’, ‘-prompt’, ‘Hi!’)); $bug = clearprompt(qw(text -def 0 –prompt), “Bug #?”);

13 ClearCase::Wrapper Not an API, a program in module form Potentially wraps all cleartool access Cannot affect Windows GUI Many cmdline features (-rec/-all/-dir)

14 ClearCase::SyncTree Analogous to citree, clearfsimport Preserves CR’s Maps filenames Takes or derives file lists Regular expression filtering Comes with synctree program

15 ClearCase::CRDB Unreleased CR analysis (impact analysis) Comes with whouses program Forward or backward analysis

16 Env::Path Simply adds methods to existing EV’s Prepend, Append, Remove InsertBefore, InsertAfter Uniqify, DeleteNonexistent Replace, Whence (take RE’s) Comes with envpath program Comes with whence program for Windows use Env::Path ‘PATH’; PATH->Remove(‘/usr/ucb’);

17 IPC::ClearTool Interop Speedup: order of magnitude, or none. Significant constant overhead CAL on Windows, coprocess on UNIX Preferred interface via ClearCase::Argv

18 ClearCase::Argv Features Command line as object Advanced Option Parsing (option sets) Interoperability Prog, opts, args Attributes: Verbosity (debug, quiet) Execution exceptions (autofail) –Can exit or call exception handler

19 ClearCase::Argv for Interop Quoting (->autoquote) Path normalization (->outpathnorm) Output (->stdout, ->stderr) Globbing (->autoglob) Xargs behavior (->qxargs, ->syxargs)

20 ClearCase::Argv examples my $ct = ClearCase::Argv->new; $ct->autochomp(1); my @co = $ct->lsco([‘-s’, ‘-all’], ‘.’)->qx; $ct->ci([‘-c’, “comment”], @co)->system; my @co = ctqx(“lsco –s –all.”); ctsystem(qw(mkelem –c comment), @co);

21 Special-purpose Objects my $ct = ClearCase::Argv->new; $ct->autofail(1); $ct->autochomp(1); my $ctq = ClearCase::Argv->new; $ct->stdout(0); $ct->stderr(0);

22 Setting attributes Per-object: $ct->stderr(1); Globally: ClearCase::Argv->stderr(1); export ARGV_STDERR=1 ClearCase::Argv->attropts; -/dbg=1 -/quiet=1 -/ipc=1

23 Question Time At This presentation Code samples Detailed documents

Download ppt "Perl/ClearCase Programming With an emphasis on UNIX/Windows interoperation David Boyce BMRCCUG 9/25/2001."

Similar presentations

Ads by Google