- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Using lexical function in a dcl-command file w...
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
Discussions
Discussions
Forums
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
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
тАО08-30-2010 07:49 AM
тАО08-30-2010 07:49 AM
Using lexical function in a dcl-command file with OpenVMS
I have a script to run on my system. This script creates a text file every day. I have the following problems. How can I solve these issues in a DCL script?
1st:
I want the first and last line completely delete from this text file. The first line is empty and the last line always contains the same text string.
Second:
For all other rows (the number of rows varies daily) I would like to delete any spaces.
I hope my English is to be understood.
Regards,
Rick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 08:20 AM
тАО08-30-2010 08:20 AM
Re: Using lexical function in a dcl-command file with OpenVMS
Welcome to the ITRC forum.
Here is one way of doing this. This method involves reading the entire file
contents and then doing the modifications required on every line.
Hence may not be the best way of achieving the desired result.
Lets say you have created a file TEMP.TXT.
Then you need to open and read all the lines of the file TEMP.TXT.
...
OPEN FILEPTR "TEMP.TXT"
READ/END_OF_FILE=END_LOOP FILEPTR Line
...
Copy all the lines of this file to a new file.
During this,
- Dont copy
- first line (first read operation)
- the last line which has a known string.
Use F$MATCH_WILD lexical to detect the pattern
- Remove spaces from other lines
Use F$EDIT lexical with "TRIM"/"COMPRESS"/"COLLAPSE " based on your requirement.
Hope this helps.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 08:58 AM
тАО08-30-2010 08:58 AM
Re: Using lexical function in a dcl-command file with OpenVMS
This is a trivial exercise in those languages.
See example below.
Real OpenVMS folks would write an TPU/EDT macro for this.
hth,
Hein
$ cre tmp.txt
first line
secone line with spaces
third line with leading and trailing space
last line
$
$ perl -ne "next if 1==$.; last if eof; s/[ \t]//g; print" tmp.txt > tmp.tmp
$
$ type tmp.tmp
seconelinewithspaces
thirdlinewithleadingandtrailingspace
$
-ne ## loop over input, no auto print
next if 1==$.; ## if the line number is 1
last if eof; ## if an end of file next
s/[ \t]//g; ## substitute
print ## the default variable $_ ... if it gets here
> tmp.tmp ## redirect output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 09:50 AM
тАО08-30-2010 09:50 AM
Re: Using lexical function in a dcl-command file with OpenVMS
The perl I showed stripped tabs (\t) and spaces. If you just are conderned with spaced, use:
s/ //g;
If you insist on DCL, try script below using
it as: $ @strip/out=new.txt old.txt
---- strip.com --------------------
$ if p1.eqs."" then exit 16
$ open/read/erro=oops file 'p1
$ read file record ! blow aways first line
$ read file record ! read and edit second record before loop
$ last = f$edit(record,"COLLAPSE")
$
$loop:
$ read/erro=oops/end=done file record
$ write sys$output last
$ last = f$edit(record,"COLLAPSE")
$ goto loop
$
$done:
$ close/nolog file
$oops:
$ exit .NOT.%x10000000 .AND. '$status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 10:33 AM
тАО08-30-2010 10:33 AM
Re: Using lexical function in a dcl-command file with OpenVMS
I think I would make an EDT command file.
$ cre MODIFY.EDT
dl
s/ //wh
.end
-1
dl
$
Explanation:
d - delete line
s/ //wh - substitute string between first and second separator ( I prefer "/", unless I need to do something with /'s, in which case I use "?" or "|", matter of taste ). That string in your question is one space.
Replace it by the string between second an third separator, in you question, nothing.
Then wh - specifies to do this over the WHole file.
. end - move to end of file
- 1 - up one line
dl - delete line
Now invoke EDT with this specification.
$ EDITT/EDT/COMMAND=MODIFY.EDT file-to-be-modified.
Save MODIFY.EDT and use as often as needed.
Note EDITT with an extra T, to avoid any EDIT symbol.
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 04:16 PM
тАО08-30-2010 04:16 PM
Re: Using lexical function in a dcl-command file with OpenVMS
As others have posted, you can write another script in whatever language you like best to edit the text file. Personally I'd choose Perl for this particular task.
[aside... hey jpe, no disrespect intended, but EDT was made obsolete in 1983 with the release of VMS V4.0, is it really appropriate to expose new people to such an old, klunky and seriously limited utility?]
Wouldn't it make more sense to go back to the script that's creating the file, and modify it to output the text file in the format you really want?
Or, look at the reasons you want the file edited, perhaps it's for input into another script. Can that be modified to apply the edits as it runs?
The point here is you can always "fix" something by adding yet another step in a process, BUT most of the time that adds extra dependencies and extra opportunities for things to go wrong, to say nothing of additional resources used in re-processing data.
In general I know I'm going in the right direction when I'm REMOVING code and simplifying processes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2010 11:47 PM
тАО08-30-2010 11:47 PM
Re: Using lexical function in a dcl-command file with OpenVMS
>>>
[aside... hey jpe, no disrespect intended, but EDT was made obsolete in 1983 with the release of VMS V4.0, is it really appropriate to expose new people to such an old, klunky and seriously limited utility?]
<<<
John, I know. Interactively I use TPU. But I have always found the non-interactive use of TPU "a bit" clumsy & untidy, where EDT worked/works just fine. (And for really complex batch editting I have been known to go back even further to SLUM (not even sure about that name anymore) or TECO, but then I require the manual.
But for not-too-complex batch editting, like this, EDT is still my choice. Despite the limits (of which the max line length has bitten me most often). Shows my age well I guess.
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2010 12:15 AM
тАО08-31-2010 12:15 AM
Re: Using lexical function in a dcl-command file with OpenVMS
thank you first for the answers. I will try the tips equal times.
An addition: Some of the answers related to other languages. However, I have a closed system. That means I can work only on the OpenVMS machine with DCL.
Greeting
Rick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2010 04:19 AM
тАО08-31-2010 04:19 AM
Re: Using lexical function in a dcl-command file with OpenVMS
The system is open.
The minds are closed.
Regards,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2010 06:06 AM
тАО08-31-2010 06:06 AM
Re: Using lexical function in a dcl-command file with OpenVMS
http://h71000.www7.hp.com/doc/73final/documentation/pdf/OVMS_SUMSLP_UTIL.pdf
Purely Personal Opinion