0

I am new to DCL.

I want to get the out put of a command in a variable and iterate result one by one.

filePath=dir /since="time_now" [.SUBDIR]*.PNG/noheader/notrail

kbang
  • 694
  • 9
  • 25

2 Answers2

2

That's just not how we roll with DCL.

We don't do pipes, we do, but not really.

DIR/SINCE=NOW ... will not give anything by definition, since nothing exists since now.

Use /OUT to stick the directory output into a file, and then read ans parse (F$PARSE and/or F$ELEMENT and/or F$LOC)

Check out HELP OPEN; HELP READ [/END]; HELP LEXICAL

Google for examples.

More advanced DCL scripts use F$PARSE, F$SEARCH and F$FILE(file,CDT) to avoid activating images and creating temp files: $ HELP LEXICAL

Google for examples. Check out yesterday stack-exhange entry ?! : OpenVMS - DELETE Line if TEXT like x

But if you are just starting... IMHO just skip DCL and stick to PERL

$ perl -e "for (<[.SUBDIR]*.PNG>) { next unless -M > 0.123; print; ... }"

Good luck! Hein

Community
  • 1
  • 1
Hein
  • 1,453
  • 8
  • 8
  • time_now not necessarily contain time at the point of command execution. I am looking for a logical which will alow me to use /since="time_now" for finding files – kbang Mar 16 '14 at 01:25
  • Well, you found it. /SINCE="dd-mmm-yyyy hh:mm:ss" or /SINCE="-3-" for 3 days ago, or /SINCE=YES(terday) or /BEFORE for the rest. Add /MODI to select modifation time instead of create time. be sure to ready up on $ HELP DIR /SINCE. – Hein Mar 16 '14 at 01:38
  • f$file_attributes has no attribute to get "since" – kbang Mar 16 '14 at 02:55
  • How do i get last modification time for a file from a lexical – kbang Mar 16 '14 at 03:03
  • "RDT". And to compare, use: write sys$output f$cvtime(f$file("sys$login:login.com","RDT")). For help use $ help lexi f$file argument. – Hein Mar 16 '14 at 04:32
0

top:

  file = f$search("[.subdir]*.PNG")
  if (file .eqs. "")then goto cont
  mtime=f$file_attribute(file,"RDT")
  if mtime.ges.build_start_time then -
      name=f>parse(file,,,"NAME")
      call CHECK "''name'"
  goto top

cont:

@Hein please review this code and suggest changes

kbang
  • 694
  • 9
  • 25
  • Also do you happen to know the lexical for searching inside a file? i want to do `search /key=(position=1,size=10) proj_fl.txt "resources/"` – kbang Mar 16 '14 at 04:57
  • 1) As I indicated in the earlier comment you need to convert the modified time, as well as build_start_time to 'comparison' style using F$CVT. 2) you might as well pass 'file' along, as 'name' has no directory ... always check with WRITE SYS$OUTPUT. 3) no lexical for searching a whole file. Need an OPEN + READ/END loop and F$SUBS and F$LOC. May be better to SEARC/WIND=0/LIMI=1/KEY=(...) and check $STATUS afterwards. Or SEARC/KEY=(...)/OUT=xxx and parse xxx. – Hein Mar 16 '14 at 12:32
  • @Hein how do i match something till end of line? $ SEARCH match.pl "=new_prj" gives key=new_prj_tc_00 , key=new_prj .I want to match only new_prj – kbang Mar 16 '14 at 19:52
  • Once you get into special string matching you may well be better off in AWK or PERL, or per-record parsing in DCL. To match to EOL use: $ SEARC/WILD=STRICT "*new_prj". Now in PERL you would use /new_prj\b/ where \b is a word boundary and match anywhere not having to worry about trailing spaces or inline comments. For PERL eol match you would probably use /new_prj\s*$/ – Hein Mar 17 '14 at 04:34
  • ya i tried search/wild=strict "new_prj/>" --> didnt work. let me experiment some more tomorrow – kbang Mar 17 '14 at 04:45
  • It did work. It did exactly what you asked. Because you did not put in a leading wildcard it had to match the whole line. RTFH – Hein Mar 17 '14 at 12:03