1828349 Members
3054 Online
109976 Solutions
New Discussion

VAX Batch Script

 
Ian M_1
Occasional Contributor

VAX Batch Script

I'm attemptting to create a script which will detect a file in a folder and transfer it to another if it is there. Once this batch job has run and has moved the file it will then be held until 2am the day after. Is there anyway of putting in a script to recognise if this file is fixed length or not. I only want fixed length files to transfer. Below is the script i currently have.

$ on error then goto retry
$ set def dai
$ set def gen6$disk
$ if f$search("gen7$disk:[ian]hello.txt") .EQS "" then goto retry
$ copy gen7$disk:[ian]hello.txt; gen7$disk:[vaxroom]
$ ren gen7$disk:[ian]hello.txt; hello.old;
$ submit /after="tomorrow+02:00" hello.com /noprint
$ exit
$ retry:
$ submit /after="+0:1:00" hello.com /noprint
$!
$ exit
$!
$ onerror:
$ on error then gosub onerror
$ return

Thanks, Ian
6 REPLIES 6
Rob Kersey
Advisor

Re: VAX Batch Script

Try using F$LENGTH()

$ str = "rob"
$ if f$length(str) .eq. 3 then write sys$output "''str'"
$ exit


HTH

Rob
Jan van den Ende
Honored Contributor

Re: VAX Batch Script

Ian,

You just have to add one line.

After the f$search insert:

$ if f$file_att(,"RAT") .eqs. "FIX"

ie, request the file attribute RecordATtribute to be FIX.

As always, HELP is your friend:

HELP LEXIC F$FILE ARG

for much more along those lines.

Success.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Mike Reznak
Trusted Contributor

Re: VAX Batch Script

Hi,
some changes are implemented down in the example...

1.use SET DEF with directory specification, if GEN6$DISK isn't logical name with full path specified. If it is disk device only, your current dir will be used and it may not exist on that disk
2. don't submit another job for retry, but use retry loop. may be put some counter in it and command to tell you, after some time, that the file isn't still there
3. don't try to submit another job for on error, but deal with the error
4. in RENAME command as you have it there, the file will be renamed to gen6$disk

$ on error then goto onerror
$ set def dai
$ set def gen6$disk
$ retry:
$ if f$search("gen7$disk:[ian]hello.txt") .EQS ""
$ then
$ wait 00:01
$ goto retry
$ endif
$ copy gen7$disk:[ian]hello.txt; gen7$disk:[vaxroom]
$ ren gen7$disk:[ian]hello.txt; hello.old;
$ submit /after="tomorrow+02:00" hello.com /noprint
$ exit
$
$onerror:
$ 'error handling here'

Mike
...and I think to myself, what a wonderful world ;o)
Hein van den Heuvel
Honored Contributor

Re: VAX Batch Script

Ian, when you write 'fixed length' are you talking about the fixed length record attribute?
If so, Jan has the solution, 'xcept that he meant RFM for "Record ForMat".

Several hints...

This 'hello.com', is that the procedure itself?
If so, then I suggest making that dynamic and independend:

$this_script = f$elem(0,";",f$env("procedure"))
:
$submit ... 'this_script

Next, you really don't want to hardcode a file name mutliple times in a single prodedure. Nor even for testing. Specially not for testing as it is too error prone.
Stick the name in a variable, use the variable.
In your case:

$file_name = "gen7$disk:[ian]hello.txt"
:
$found_name = f$search(file_name)
$if found_name .EQS."" ...
$stripped_name = f$elem(0,";",found_name) + ";"
$if "FIX".EQS.f$attr(stripped_name,"RFM") ...
$copy 'stripped_name gen7$disk:[vaxroom]
$rena 'stripped_name .old
:

$copy 'filename


hth,
Hein.
Antoniov.
Honored Contributor

Re: VAX Batch Script

Ian,
could you please explain what you fixed lenght mean?
From my point of view I think you want to know if something is writing on it.
Some time ago, I wrote some statements to solve this:
$! Var FAL doesn't have to exist
$ IF F$TYPE(FAL).NES."" THEN DELETE/SYMB FAL
$! Now I want to catch error
$ SET NOON
$ DEFINE SYS$ERROR NLA0:
$ DEFINE SYS$OUTPUT NLA0:
$! If file is in use, FAL can't be created
$! due error condition
$ FAL=F$FILE(,"EOF")
$! Restore error trap
$ DEASS SYS$OUTPUT
$ DEASS SYS$ERROR
$ SET ON
$! If var FAL doesn't exist file is in use
$ IF F$TYPE(FAL).EQS."" THEN GOTO FILE_IN_USE
$! here file is free

Antonio
http://it.openvms.org

Antonio Maria Vigliotti
Anton van Ruitenbeek
Trusted Contributor

Re: VAX Batch Script

Ian,

I think the answers given are one you need.
But try to get rid of 'SET DEFAULT' in routines. You know the filespec. so use it.
I'm at a site whith OpenVMS managers (doing this for several years) and they are all using 'set default' always, and a few weeks ago a compleet system wasn't working because a manager did SET DEFAULT device:[000000] and executed a .COM that by accident did change the protection of the 000000.dir ! Whole drive readonly and a whole company confused!

I did mentioned this several times the last months of not doing this. It's not funny when I'm right.

AvR
NL: Meten is weten, maar je moet weten hoe te meten! - UK: Measuremets is knowledge, but you need to know how to measure !