Operating System - OpenVMS
1753873 Members
7468 Online
108809 Solutions
New Discussion юеВ

UNIX procedure equivalent in OVMS?

 
SOLVED
Go to solution
Andrew Yip
Advisor

UNIX procedure equivalent in OVMS?

Hello!
I'm a newbie to VMS scripting and i would greatly appreciate if someone would offer me some solutions here.

I've been trying to perform the following procedure in OpenVMS as i've done well in UNIX.

foreach file (`ls `)
mem del $file
end

What exactly i'm trying to do here is to capture a list of existing files in a specified directory and delete those same files residing in a connected industrial machine. The statement "mem del" is basically delete files in the machine's memory.

On top of this, there's another problem with VMS. I noticed when i performed a "directory" command on a location. All the files comes with a version number at the end. This would pose a problem when i try to use the filenames to delete in my machine's memory. In this case, i would need to truncate the trailing version numbers.

How can i get these done with similar commands which i'd used in my UNIX script? Please help....please?!

Augustine Andrew
23 REPLIES 23
Uwe Zessin
Honored Contributor

Re: UNIX procedure equivalent in OVMS?

The mechanism to loop over files in a directory is by using a "lexical function" named F$SEARCH():

-----
$LOOP:
$ FNAM = F$SEARCH ("*.*;*")
$ if FNAM .eqs. "" then $ goto DONE
$! delete 'FNAM'
$ write SYS$OUTPUT FNAM
$ goto LOOP
$DONE:
$ exit
-----

> All the files comes with a version number at the end. This would pose a problem when i try to use the filenames to delete in my machine's memory.

You MUST specify a version number (or the "*" wildcard) in order to be able to delete a file.


> i would need to truncate the trailing version numbers.

In case you need this for something else - use:
$ directory *.*; /select=file=noversion /column=1
.
labadie_1
Honored Contributor

Re: UNIX procedure equivalent in OVMS?

I am not sure there is a Vms equivalent of "mem del".

If you want to check the files in a directory, use f$search, and you can check the help with
$ help lexical f$search

an example
$ loop:
$ file = f$search("my_directory:*.dat")
$ if file.eqs."" then exit
$ !your code about that file, here a search (grep in Unix) ...
$ search 'file my_string
$ goto loop:

With f$search, if you do several concurrent searches, you will use the stream id (here 1 and 2)

$ START:
$ COM = F$SEARCH ("*.COM;*",1)
$ DAT = F$SEARCH ("*.DAT;*",2)
$ SHOW SYMBOL COM
$ SHOW SYMBOL DAT
$ IF (COM.EQS. "") .AND. (DAT.EQS. "") THEN EXIT
$ GOTO START
Mike Reznak
Trusted Contributor

Re: UNIX procedure equivalent in OVMS?

Hi,

to get only the file name for use in remote specification use F$PARSE. [may be omit the version]

FNAMSHORT = f$PARSE(FNAM,,,"NAME") + f$PARSE(FNAM,,,"TYPE") [ + f$PARSE(FNAM,,,"VERSION") ]

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

Re: UNIX procedure equivalent in OVMS?

Andrew,


residing in a connected industrial machine. The statement "mem del" is basically delete files in the machine's memory.

The way I interpret your question: "at the VMS system there is a directory in which files reside, copies of which exist in the memory of the connected machine".

If so:
- what is the OS of those machines?
- do you just need to remove the memory copies, or also the VMS files?

How to get the list of files is by any of the given methods.
If you just beed a list, I would use the last line given by Uwe, perhaps with the addition of /NOHEADER and /NOTRAILER.
Put that in a file ( /OUTPUT= filename ). or use PIPE, to feed your original example.

If you also want to delete the VMS file, then use the file mechanism. You have to add the version number again (use wildcard, ;* ) for a VMS DELETE.
If there is no need to remove both synchronously, use the PIPE method, and for VMS just delete the whole bunch at one go: DELETE *.*;*

hth,

Success

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Andy Bustamante
Honored Contributor

Re: UNIX procedure equivalent in OVMS?


You can also select files with

$ delete /before=
If you don't have time to do it right, when will you have time to do it over? Reach me at first_name + "." + last_name at sysmanager net
Andrew Yip
Advisor

Re: UNIX procedure equivalent in OVMS?

Hey guys!

Wow! This is like family! What prompt response we have here?! You guys are great!
But anyway, i still have some problems after trying out your wonderful suggestions.
============================================
Hi Uwe,
Your idea works. But i've a problem when i need to delete the list of files generated by the F$SEARCH function in a different directory. FNAM returns the full directory path of the search list. Hence, i wouldn't be able delete the same files in any other directory other than the original search location. Do you have a fix on this small glitch?

On the other hand, your truncation method doesn't work on my machine.It seems like mine doesn't support the 'file' keyword.
*[%DCL-W-IVKEYW, unrecognized keyword - check validity and spelling
\FILE\]

How do i check the version of my OVMS for scripting compatibility? I felt that my OVMS's scripting language works a little different. Hmm...strange!
============================================
Hi Labadie,
Thanks for your ideas too!
"Mem Del" is not a OVMS command, it's my other machine's command. It doesn't matter.
Thanks!
============================================
Hi Mike,
Thanks for your command there although i don't understand it.
The command line works for me, but it returns an error msg when i invoke it.
*[%DCL-W-SYMDEL, invalid symbol or value delimiter - check command syntax]
What is this all about?
============================================
Hi Jpe,
Yes, you've got my point.
The OS of my connected machine doesn't matter. It's making use of OVMS to communicate with it. I only need to delete the memory copies in that machine using the "mem del" command. No issues with that.

Sorry, i may sound stupid but how do i utilize the /NOHEADER & /NOTRAILER qualifiers to Uwe's command?

/OUTPUT doesn't seemed to work on my OVMS. My OVMS works a little different from others, i think.
============================================

Best Regards,

Andrew

Joseph Huber_1
Honored Contributor
Solution

Re: UNIX procedure equivalent in OVMS?


Your alter ego on computing.net specified a bit more precisely that You have VMS 5.5 !
And in this ANCIENT version there was rarely a /output qualifier for commands.

So You have to redirect output of the dir command by
define/user sys$output somename.tmp
dir ...
to achieve the same as dir/output=somename.tmp .

And as I have said in computing.net, parse the file-specification into nt=name+type, then
delete thedisk:[thedirectories]'nt';*

http://www.mpp.mpg.de/~huber
Kris Clippeleyr
Honored Contributor

Re: UNIX procedure equivalent in OVMS?

Andrew,

Attached command procedure works for me.
Note that I haven't tested it thoroughly.

Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Jan van den Ende
Honored Contributor

Re: UNIX procedure equivalent in OVMS?

Andrew,

So, VMS 5.5, and the procedure runs on VMS, to operate on the remote system, and the directory over there is different (say: remdir)
(supposing MEM DEL is doing the same as on *X:)

$ DEFINE SYS$OUTPUT DIRLIS.TMP
$ DIRE /NOHEADER/NOTRAIL/COL=1
$ OPEN IFI DIRLIS.TMP
$LOOP:
$ READ IFI FIL /END=DONE
$ REMFIL = + F$PARSE(FIL,,,"NAME") + F$PARSE(FIL,,,"TYPE")
$ MEM DEL 'REMFIL'
$ !? DELETE 'FIL' !? maybe local del as well?
$ goto loop
$DONE:
$ CLOSE IFI
$ DELETE DIRLIS.TMP.*


hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.