Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

How to control execution time of DCL commands

 
SOLVED
Go to solution
JVK_1
Occasional Visitor

How to control execution time of DCL commands

Hi,

I am using Open VMS version 7.3-2.
I have a problem executing a command procedure with FTP commands in it. Sometimes the FTP command does not exit due to slow connections. In such a case a manual CTRL+Y needs to be done but instead i want to abort and continue with the remaining execution automatically. How can i run the command procedure for certain duration of time so that it terminates irrespective of whether the FTP commands have been executed or not?
16 REPLIES 16
Karl Rohwedder
Honored Contributor

Re: How to control execution time of DCL commands

You may spawn individual commands or procedures using /NOWAIT, wait a specific amount of time in the master process and then continue and/or kill the subprocess.

regards Kalle
JVK_1
Occasional Visitor

Re: How to control execution time of DCL commands

hi Kalle,

Thanks a lot for your suggestion. I'll try it out.

Regards,
VIjay.
Robert Gezelter
Honored Contributor

Re: How to control execution time of DCL commands

Vijay,

Another alternative is to use the batch queues, although there is no guarantee that the job starts immediately (the queue may be busy or stopped).

In either case, be very careful that it is possible to tell the difference between a completed and uncompleted task. It is all too easy to find that ftp has transferred less than a complete file, and have later stages of the application become confused by processing a truncated file.

- Bob Gezelter, http://www.rlgsc.com
JVK_1
Occasional Visitor

Re: How to control execution time of DCL commands

Hi Robert,

Thanks a lot for the reply. Will try to implement.
I have another question. Can the same command procedure be invoked simultaneously by different processes passing different parameters (like FTP address and file names) ? something like multithreading..In such a case where each request to that command procedure is processed seperately (and simultaneously) using NOWAIT will be easier..
JVK_1
Occasional Visitor

Re: How to control execution time of DCL commands

sorry BOB for the wrong name used..mistake.. :)
Steven Schweda
Honored Contributor

Re: How to control execution time of DCL commands

> [...] Can the same command procedure be
> invoked simultaneously by different
> processes [...]

Normally, yes (unless your command procedure
does something inappropriate, like, say, use
a fixed name for a temporary file).

> [...] something like multithreading [...]

More like multiprocessing.
Jess Goodman
Esteemed Contributor

Re: How to control execution time of DCL commands

Here's a command file we use for this problem. Right before the FTP command spawn this commmand file like this:
$ PID = F$GETJPI(0,PID)
$ SPAWN /PROCESS=SUB_'PID' -
@PROCESS_WATCHER 'PID' 00:05:00
$ COPY/FTP ...
$ STATUS = $STATUS
$ STOP SUB_'PID'
$ IF (.NOT.STATUS) THEN ...

$!----------PROCESS_WATCHER.COM--------
$ SET NOON
$ WATCHED_PID := 'P1' !Pass process ID in as P1
$ IF (WATCHED_PID .EQS. "") THEN WATCHED_PID = F$GETJPI(0,"MASTER_PID")
$ P2 = P2-"+" !Pass max wait time in as P2 w or w/o +
$ IF (P2 .EQS. "") THEN P2 = "00:02:00"
$ END_CTIME = F$CVTIME("+''P2'")
$ IF (.NOT.$STATUS) THEN END_CTIME = F$CVTIME("+00:02:00")
$ INTERVAL := 'P3' !Interval between checking for new I/O
$ IF (INTERVAL .EQS. "") THEN INTERNVAL := 00:00:30
$!----------------
$! PRIME DATA
$!-----------
$ CURBIO = F$GETJPI(WATCHED_PID,"BUFIO")
$ IF (.NOT.$STATUS) THEN EXIT
$ CURDIO = F$GETJPI(WATCHED_PID,"DIRIO")
$LOOP:
$ LASTBIO = CURBIO
$ LASTDIO = CURDIO
$ WAIT 'INTERVAL'
$!--------------------
$! CHECK CURRENT INFO
$!--------------------
$ CURDIO = F$GETJPI(WATCHED_PID,"DIRIO")
$ CURBIO = F$GETJPI(WATCHED_PID,"BUFIO")
$ DIO = CURDIO - LASTDIO
$ BIO = CURBIO - LASTBIO
$! If no I/O occured or if this has been going on too long kill our master.
$ IF ( (DIO.GT.0 .OR. BIO.GT.0) .AND. -
F$CVTIME() .LTS. END_CTIME ) THEN GOTO LOOP
$ FEXIT /ID='WATCHED_PID'
$ EXIT
$! this process is spawned from a command procedure that
$! is doing an inline COPY/FTP or another FTP process.
$! it could be any process really.
$! it will wait the time in P2 and FEXIT the process ID in P1
$! passed in as p2 if wait time is reached or no I/O in any P3 interval.
$!----------------------------------------------------------
I have one, but it's personal.
JVK_1
Occasional Visitor

Re: How to control execution time of DCL commands

Hi Jess,

I have tried out your solution. Actually am new to DCL coding.
I'm getting the following error after executing the above command procedure.

$ FEXIT /ID=00036D43
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
\FEXIT\

Thanks in advance for the help.

Regards,
Vijay.
Wim Van den Wyngaert
Honored Contributor
Solution

Re: How to control execution time of DCL commands

Must be about the same ad STOP. Just replace FEXIT by STOP.

Wim
Wim
Robert Gezelter
Honored Contributor

Re: How to control execution time of DCL commands

Vijay,

As I believe Steve has already commented, the answer is that multiple processes (and as a result, batch jobs) can execute the same command file simultaneously. This presumes that the command file does not use a fixed, fully qualified filename in a way that precludes simultaneous execution.

If a command procedure uses a temporary file TEMPORARY.TMP, then two sessions on the same account will be trying to use the same file. A solution to this is to dynamically create file names using the F$GETJPI lexical function an the PID argument.

The same is true for logical names outside of the process-context.

- Bob Gezelter, http://www.rlgsc.com
Martin Vorlaender
Honored Contributor

Re: How to control execution time of DCL commands

Re: What is FEXIT?

I'd think it's a Forced Exit - so it'd be a STOP/IMAGE - rather than a DELPRC, a STOP.

Since STOP/IMAGE wasn't implemented for a long time (pre 7.3-2?), everyone had his own image that called $FORCEX.

$FORCEX would be the right choice IMHO, since the intent is to kill the blocking image runningin the master process, rather than the master process itself.

cu,
Martin
Hoff
Honored Contributor

Re: How to control execution time of DCL commands

Not exiting on a timeout is either a bug in your procedure, or a bug in the ftp tool. If you're not using COPY /FTP, start there. The classic FTP utility interface is somewhat more difficult to script than is COPY /FTP.

I don't remember off-hand if COPY /FTP has a qualifier with a timeout specifier; that would be a reasonable enhancement, if not.

Is OpenVMS a prerequisite here or are add-ons permissible? There are hosts that deal with this sort of file transfer operation better (either with built-in tools or with some widely-available add-on software) and that can run parallel and partial-restart ftp transfers. (I'd expect Perl or another existing library has some options here, too. LWP::UserAgent and Net::FTP from libnet come to mind.) Here's a libnet set-up for ftp with a 100 second timeout specified.

use Net::FTP;
my $ftp = new Net::FTP( hostname, Timeout => 100 );
Jess Goodman
Esteemed Contributor

Re: How to control execution time of DCL commands

Yes. "FEXIT" should be replaced with "STOP/IMAGE". Sorry about that, I didn't notice that. As Martin guessed FEXIT was our own implementation of STOP/IMAGE which was required before VMS 7.3.
I have one, but it's personal.
John Gillings
Honored Contributor

Re: How to control execution time of DCL commands

re: Bob:

>If a command procedure uses a temporary
>file TEMPORARY.TMP, then two sessions on
>the same account will be trying to use the
>same file. A solution to this is to
>dynamically create file names using the
>F$GETJPI lexical function an the PID
>argument.

Even better, if you're V7.3 or higher, use F$UNIQUE.

$ myfile=F$PARSE(F$UNIQUE(), "SYS$SCRATCH:.TMP;")

Even better than that is to use PIPE and avoid temporary files altogether.
A crucible of informative mistakes
Wim Van den Wyngaert
Honored Contributor

Re: How to control execution time of DCL commands

No f$uniq on my 7.3.

Wim
Wim
labadie_1
Honored Contributor

Re: How to control execution time of DCL commands

Wim

Let's say Vms 7.3-2 :-)