C-Kermit 7.0 Case Study #01

[ Previous ] [ Next ] [ Index ] [ C-Kermit Home ] [ Kermit Home ]

Article: 10879 of comp.protocols.kermit.misc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: C-Kermit 7.0 Case Study #01 - Cleaning Out Beta-Test Binaries
Date: 7 Jan 2000 23:53:58 GMT
Organization: Columbia University

As time permits, we're going to try to show off some of C-Kermit 7.0's new features in a series of case studies posted here. If you'd like to post your own stories, feel free -- that's what this newsgroup is for! Ditto if you'd like to suggest a topic to be presented.

Today's case study shows how C-Kermit 7.0 can be used to clean up after itself. As those of you who have been following our neverending saga know, the C-Kermit 7.0 release was preceded by a long series of Alpha and Beta tests, in each of which we tried to make binaries available for as many platforms as possible. For example, the Solaris 2.5.1 Intel test binary names look like:

  cku193a03.solaris25-i386-2.5.1  (Edit 193 Alpha Test 03)
  cku195b07.solaris25-i386-2.5.1  (Edit 195 Beta  Test 07)
  cku196b11.solaris25-i386-2.5.1  (Edit 196 Beta  Test 11)
And then the final release binary for this platform is called:
Within a few days after release, we had about 170 final binaries (keep 'em coming!), and hundreds more test ones, each binary consuming about a megabyte of disk space. Before long, our server disk was running out of space.

Problem: Given about 600 C-Kermit binaries, how to remove test binaries for builds that have a final release, but preserve test binaries for the other platforms that we don't yet have final builds for?

Here's how to do it with a Kermit script (the lines are tagged by numbers that are not part of the script):

  1. #!/usr/local/bin/kermit +
  2. cd /pub/ftp/kermit/bin/
  3. space
  4. .\%n := \ffiles(ck?196[-.]*,&a)
  5. for \%i 1 \%n 1 {
  6.     .\%f := \&a[\%i]
  7.     echo \%f...
  8.     .\%g := \freplace(\%f,196,19[3-6][ab][0-9][0-9])
  9.     .\%m := \ffiles(\%g,&b)
 10.     if ( > \%m 0 ) {
 11.         echo { MATCHES: \%g: \%m}
 12.         for \%j 1 \%m 1 {
 13.             ; echo {   \flpad(\%j,2). \&b[\%j]}
 14.             delete /verb \&b[\%j]
 15.         }
 16.     }
 17. }
 18. space
 19. exit

Here's a line-by-line explanation:

  1. This line is used in UNIX to make the script directly executable from the shell prompt, just like a shell script. For details, see Section 7.19 of the update notes.

  2. We set our current directory to the Kermit binaries directory.

  3. The SPACE command tells how much disk space is used and free.

  4. This line shows a bunch of new stuff. ".\%n := " is a new way of assigning values to variables, explained in Section 7.9 of the update notes. It means the same as "assign \%n ". There are several other forms too, each for a different purpose. The value in this case is whatever is returned by the call to the built-in function \ffiles(), namely the number of files that matches the given pattern. This function has been with us for years, but there are two new things to notice in the argument list. First, the