Re: DCL script for a dummy like me ...

From: JF Mezei (jfmezei.spamnot_at_teksavvy.com)
Date: 01/28/05


Date: Fri, 28 Jan 2005 17:30:51 -0500

eiderdoo wrote:
>
> I'm trying to do my first DCL scripts but I'm in trouble.
> I need to count the number of lines for each file at a given directory
> and keep the result (name of the file and number of lines) in a new
> output file.

You will want to look at the lexicals: F$SEARCH (HELP LEX F$SEARCH )

To go through list of files in a directory:

$SAY :== " write sys$output"
$OPEN/WRITE logfile MYLOGFILE.TXT
$!
$LOOP1:
$ myfile = F$SEARCH("$disk1:[dir1.dir2]*.*")
$ if myfile .eqs. "" then goto endloop1
$! myfile now contains a valid fully qualified file name
$ say "Processing: ''myfile'"
$ call COUNTREC myfile
$ write logfile "''myfile' contains ''records' records"
$goto LOOP1
$!
$ENDLOOP1:
$say "Done with list of files"
$close logfile
$EXIT

$!
$!
$COUNTREC: SUBROUTINE
$ OPEN/READ/SHARE TEMP 'p1
$ records == 0
$ LOOP2:
$ READ/END=endloop2 temp buffer
$ records == records + 1
$ GOTO LOOP2
$!
$ ENDLOOP2:
$ CLOSE TEMP
$ EXIT
$ENDSUBROUTINE

Using the HELP command you can pretty much get detailed information on
the above verbs used. F$things are lexicals and can be reached with HELP
LEXICAL F$thing

the "==" sets a scobe to be global so that the value is shared between
portions of scripts and between scripts executing in the same process
(eg: one scruiupt invoking another).

If you want the output written to file in a neater way, you can lookup
F$FAO which is a glorified equivalent of printf.

Obiwan may have told Luke to use the Force. But the VMS engineers tell
us to use HELP :-)



Relevant Pages

  • Re: DCL script for a dummy like me ...
    ... >> I'm trying to do my first DCL scripts but I'm in trouble. ... > $ call COUNTREC myfile ... > Using the HELP command you can pretty much get detailed information on ... F$things are lexicals and can be reached with HELP ...
    (comp.os.vms)
  • Re: finding group user belongs too
    ... Thank you all for your input, have tried all the scripts, and would like to ... aFile.Delete ' now delete the output file. ... Function DisplayGroups (strObjectADsPath, strSpaces, dicSeenGroup) ... colGroups = Array) ...
    (microsoft.public.scripting.vbscript)
  • Re: Script to create huge sample files
    ... Say I have scripts that dumps some contents on to an output file handler ... With such scripts I have noticed 2 types of behaviour. ... to do with output buffer. ... Shlomi Fish http://www.shlomifish.org/ ...
    (perl.beginners)
  • How do I redirect output to a file and to the console screen?
    ... I'm doing some TELNET and FTP sessions with my scripts. ... redirect all the output to an output file, ...
    (comp.lang.python)