Welcome to VMS world.Your first line of knowlegde is HELP on the commandline ;-).
Other sources for help are www.openvms.org and the OpenVMS forum on www.hp.com (search for 'ITRC'. You need to register there but it's free)
To extract a specific field from a line:
It depends. If the fields are separated by a specific character, use F$ELEMENT:
Example (Type each line, without starting "$", at the prompt. ($ is the standard VMS prompt, usually used in typing when specifying code)
$var="1#one#st#first"
$nr=f$element(0,"#",var)
$nam=f$element(1,"#",var)
$ord=f$element(2,"#",var)
$onm=f$element(3,"#",var)
$! (! = comment character)
$sho sym nr
$sho sym nam
$sho sym ord
$sho sym onm
If you have no such delimiter, the command to extract part of a string is F$EXTRACT. You specify a starting position (actually: offset in the string, where the first character is at offset 0) and the size.
If you know what value you're looking for and it's size, but don't know the offset, use F$LOCATE to find the offset.
Example:
$ months="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
$ dt = F$TIME() ! unix 'date' but in a different format
$ mmm=f$extract(3,3,dt)
$ m3= f$locate(mmm, months)
$ mm = m3/3 +1
$ sho sym mm
(Beware: although VMS is in essence case-insensitive, DCL is NOT! F$SEARCH will not find mm in months if case is different!)
If you specify:
$ months="JAN/FEB/MAR/APR/MAY/JUN/JUL/AUG/SEP/OCT/NOV/DEC"
you can do:
$ i=0
$LOOP:
$ IF F$ELEMENT(I, months) .EQS. mm THEN GOTO ENDLOOP
$ IF I .LE. 11 THEN
$ I = I+1
$ GOTO LOOP
$ ELSE
$ WRITE SYS$OUTPUT "Invalid month"
$ GOTO ENDLOOP
$ ENDIF
$ ENDLOOP
$
Just try them out.
'Scripting' in unix can be done in VMS as well, of course. Just invoke the editor, put above commands in a file and save it as a_job.COM. Start it by specifying:
$ @a_job
and it will execute each command.
But again: use HELP (and check the HP.COm site for OpenVMS documentation)
I don't know the unix 'head' command, but 'tail''s equivalent in VMS is:
$ TYPE/TAIL <filename>
Willem
Willem Grooters