- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: UNIX procedure equivalent in OVMS?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2005 08:24 PM
11-29-2005 08:24 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2005 08:30 PM
11-29-2005 08:30 PM
Re: UNIX procedure equivalent in OVMS?
-----
$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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2005 08:40 PM
11-29-2005 08:40 PM
Re: UNIX procedure equivalent in OVMS?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2005 08:49 PM
11-29-2005 08:49 PM
Re: UNIX procedure equivalent in OVMS?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2005 11:42 PM
11-29-2005 11:42 PM
Re: UNIX procedure equivalent in OVMS?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 04:30 AM
11-30-2005 04:30 AM
Re: UNIX procedure equivalent in OVMS?
You can also select files with
$ delete /before=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 06:36 PM
11-30-2005 06:36 PM
Re: UNIX procedure equivalent in OVMS?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 07:30 PM
11-30-2005 07:30 PM
SolutionYour 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';*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2005 08:11 PM
11-30-2005 08:11 PM
Re: UNIX procedure equivalent in OVMS?
Attached command procedure works for me.
Note that I haven't tested it thoroughly.
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 07:44 AM
12-01-2005 07:44 AM
Re: UNIX procedure equivalent in OVMS?
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
$ OPEN IFI DIRLIS.TMP
$LOOP:
$ READ IFI FIL /END=DONE
$ REMFIL =
$ 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 05:46 PM
12-04-2005 05:46 PM
Re: UNIX procedure equivalent in OVMS?
Jpe,
Your method works faster than having to use the f$search and IF-THEN-ELSE statements.
By the way, how do i append my next output when applying the define method?
E.g:
DEFINE SYS$OUTPUT test.log
show time
DEASSIGN SYS$OUTPUT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 06:03 PM
12-04-2005 06:03 PM
Re: UNIX procedure equivalent in OVMS?
$ define sys$output time.tmp
$ show time
$ deassign sys$output
$ append time.tmp test.log
%APPEND-W-INCOMPAT, USER_1:[ZESSIN]TIME.TMP;1 (input) and USER_1:[ZESSIN]TEST.LOG;1 (output) have incompatible attributes
$ delete time.tmp;
$ type test.log
abc
___5-DEC-2005 07:55:59
$
Another idea:
$ open /append t_log test.log
$ write t_log " "+f$cvtime(f$time(),"absolute")
$ close t_log
$ type test.log
abc
___5-DEC-2005 07:55:59
__5-DEC-2005 07:59:51.50
$
(I have replaced the leading spaces in the file output with underscores "_" to better illustrate the difference, because ITRC eats spaces :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 08:05 PM
12-04-2005 08:05 PM
Re: UNIX procedure equivalent in OVMS?
Your method works faster than having to use the f$search and IF-THEN-ELSE statements.
Although it has nothing to do with the original question,
but this statement sounds unjustified.
Writing the output of a command to a file, then reading it is clumpsy as long as there is an equivalent function built into DCL like in this case DIRECTORY/OUTPUT vs. f$search.
And why creating a file,invoking an image, opening and reading a file should be faster than DCL-internal directory search is beyond my imagination.
Could You explain how You measured it being faster ?
Directory output to a file is IMHO only needed, if some /EXCLUDE or other criteria can't be achieved easily inside DCL, or if the file list has to be sorted somehow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 09:49 PM
12-04-2005 09:49 PM
Re: UNIX procedure equivalent in OVMS?
I've just compared a simple F$SEARCH loop finding 200 files with a DIR /OUT and reading its output: the DIR solution is faster:
- is uses less CPU and elapsed time and BufIO
- is needs more hard faults and DirIO
Normally I would prefer the DCL F$SEARCH solution, because you are not dependant on the format of the DIR output.
regards Kalle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 10:38 PM
12-04-2005 10:38 PM
Re: UNIX procedure equivalent in OVMS?
- is uses less CPU and elapsed time and BufIO
- is needs more hard faults and DirIO
Remove Elapsed Time from these lines, and it means, that the amouts of Elapsed Time are configuration-dependant. Much CPU power and Memory favors the DIR solution, good Caching and fast disk IO favors the F$SEARCH.
-- although whenever possible a personally favor lexical function solutions over output-parsing!
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:07 AM
12-05-2005 12:07 AM
Re: UNIX procedure equivalent in OVMS?
I made tests with my slowest and fastest CPUs, and it seems that only for short (few hundreds) number of files DIRECT/output wins. In all other cases f$search loops are faster, and gain with the number of files.
Seems that f$search has a bigger 'pedestal' at initialization.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:28 AM
12-05-2005 12:28 AM
Re: UNIX procedure equivalent in OVMS?
And one additional note on the differences:
DIRECTORY lists ALIAS files/directories,
f$search does not return aliases !
So it may well make a difference wether the list of files is for processing or e.g. for delete/remove.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:36 AM
12-05-2005 12:36 AM
Re: UNIX procedure equivalent in OVMS?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:45 AM
12-05-2005 12:45 AM
Re: UNIX procedure equivalent in OVMS?
if You explicitely do f$search("[.dir]*.*"), then yes, it returns files wether being aliases of some files in other directories.
But say You have [.a] and [.b] being an alias directory of [.a], then f$search [...]*.* returns the files only once, not the files in [.b].
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:56 AM
12-05-2005 12:56 AM
Re: UNIX procedure equivalent in OVMS?
Uwe is right, I had by chance exactly as many files to purge as I had aliases resulting in the same difference of number of files between
f$search() and DIRECTORY.
So not the alias behaviour is different, but
f$search("*.*") is not the same as
directory *.*
the directory command defaults to version ";*" if not explicitely version 0 (";" or ";0") is specified, while f$search("*.*") returns only the highest version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 01:10 AM
12-05-2005 01:10 AM
Re: UNIX procedure equivalent in OVMS?
slight addendum:
f$search CAN find all versions of files, but for that you have to explicitly specify ;*
So, the default for DIR is ALL versions, you have to specify ;0 for the highest, while the default for f$search is the highest version, you have to specify ;* for all.
And of course, BOTH support ;-1 etc for the second highest etc, and ;-0 for the LOWEST version.
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 12:06 PM
12-05-2005 12:06 PM
Re: UNIX procedure equivalent in OVMS?
E.g.
%date >> test.log
%pwd >> test.log
%cat test.log
/export/home/user
Tue Dec 6 08:58:01 singapore 2005
Uwe,
your method would require the outputs to be in seperate files 1st before appending them into 1 file right?
Is there a way to perform the append function simliar to the above UNIX method?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 04:54 PM
12-05-2005 04:54 PM
Re: UNIX procedure equivalent in OVMS?
$ pipe cmd > append sys$pipe: file
The > Operator always creates a new file.
regards Kalle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2005 05:11 PM
12-05-2005 05:11 PM
Re: UNIX procedure equivalent in OVMS?
I can't use your method.
My VMS version 5.5-2 doesn't allow that.