Operating System - OpenVMS
1748162 Members
3658 Online
108758 Solutions
New Discussion юеВ

file renaming and Entry input

 
SOLVED
Go to solution
nipun_2
Regular Advisor

file renaming and Entry input

Hi,
I need to automate certain mechanical tasks. However, I have two separate problems right now.

My dir structure fixed for all projects
projDir1 - models.dir
- com.dir
- data.dir

Problem 1

Now I have setup a script

which moves *.EXT files to models.dir
now I wish to rename the latest version file(*.EXT) in models.dir to

*_GFILT.EXT
like the following
$RENAME [.models]*.ext [.models]*_GFILT.EXT

So I need to add/insert the stringg "_GFILT"

Currently I do
NAME_EXT=F$Search("[.models]*.EXT")
NAME = NAME_EXT - "AIM;1"
NAME_NEW = NAME +"_GFILT.AIM"

RENAME *.AIM 'NAME_NEW

However, F$search understandably keeps track of the older path so
when i make a new projDir2

projDir2 - models.dir
- com.dir
- data.dir

it still searches in "projDir1" instead of "projDir2"

If you are aware of better way to insert "GFILT" please let me know or to clear pointer of F$Search

Problem 2

In the above projects I start a que_base which on it's completion generates data_que

now I need to wait for que_base to end in order to start the next type of que to process data_que

How can I automate this to get final_data

so projDir1_data -> start que_base -> data_que->start que_next->final_data

if there is simple way please let me know

Thanks in advance.

3 REPLIES 3
Uwe Zessin
Honored Contributor
Solution

Re: file renaming and Entry input

You can easily invalidate the F$SEARCH() context. In the history I used
$ S = F$SEARCH("@")

but Jan had a better idea:
$ S = F$SEARCH ("INVALIDATE_SEARCH_CONTEXT")

It is highly unlikely that you have a file by that name, right?

For problem 2:
it sounds like you are working with batch jobs, but I am not absolutely sure - would be nice if you can explain a bit more details.

If my guess is right, can you SUBMIT them for batch processing in a batch queue with /JOB_LIMIT=1. ?
.
Karl Rohwedder
Honored Contributor

Re: file renaming and Entry input

F$Search uses a 2nd parameter (Context), so that you can nest F$SEARCHes, e.g. an outer loop uses F$SEARCH(file,1212) and an inner loop f$SEARCH(file2,1313).

I'm not sure, if I understand your 2nd problem, but you can wait for the completion of a batchjob with SYNCHRONIZE. The SUBMIT command returns the entrynumber of a batchjob in the DCL symbol $ENTRY.

regards Kalle
Phillip Thayer
Esteemed Contributor

Re: file renaming and Entry input

The way that you have problem 1 stated shows that you are useing the directory as "[.models]" which seems to indicate that you are relaying on your current default directory to be correct. Try setting your default directory to [projdir2] before you start the next f$search for "[.models]". Also using the f$search context is always a good idea so that you don't get searches mixed up between each other.

For problem2 I agree that we need more specific information on the problem. If you are using the SUBMIT command then try sumbitting it with a /NAME=job-name and then use the SYNCHRONIZE command in DCL to tell if it is finished. If you are submitting multiple procedures to the batch job and you want to watch the queue until all the jobs are finished then you need to use a gosub as follows:

$CHECK_OPTIMIZE_JOB:
$ wait 00:10:00.00
$ temp = f$getqui("")
$ optimize_done = "Y"
$ write sys$output "Checking SYS$BATCH for OPTIMIZE_FILE at ''f$time()'"
$QLOOP:
$ qname = f$getqui("DISPLAY_QUEUE","QUEUE_NAME","SYS$BATCH*")
$! if qname .eqs. "" then goto exit_check_optimize_job
$JLOOP:
$ jname = f$getqui("DISPLAY_JOB","JOB_NAME",,"ALL_JOBS")
$ if jname .eqs. "" then goto end_wait_loop
$! write sys$output jname
$ if jname .eqs. "OPTIMIZE_FILE"
$ then
$ optimize_done = "N"
$ write sys$output "Found an OPTIMIZE_FILE job in SYS$BATCH"
$ goto end_wait_loop
$ endif
$ goto jloop
$!
$END_WAIT_LOOP:
$ if optimize_done .eqs. "Y" then goto exit_check_optimize_job
$ goto check_optimize_job
$!
$EXIT_CHECK_OPTIMIZE_JOB:
$ return

This basically looks for a specific file name in the bqtch queue and if it finds one still in the queue it waits and looks again. If there it doesn't find one in the queue then it will exit and your procedure can continue with the next batch of files to submit.

Phil
Once it's in production it's all bugs after that.