- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: search command search-string - how search for ...
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
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
тАО03-09-2007 09:28 AM
тАО03-09-2007 09:28 AM
We have some software programs that generate log files which we must search. The target string includes not just one single quote and some specific character, but: "... 'A' "
How may we avoid DCL string substitution parsing to look for the text string 'A' in several files using the OpenVMS SEARCH command?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 09:40 AM
тАО03-09-2007 09:40 AM
Re: search command search-string - how search for '<char>' ?
entirely clear.
What's wrong with this?:
alp $ type apo.txt
abcdefg
abc'defg
abcd'efg
abc'd'efg
alp $ sea a*.txt "'d'"
******************************
ALP$DKA0:[SMS]APO.TXT;1
abc'd'efg
Inside quotation marks (""), you need two
apostrophes ('') to get symbol evaluation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 09:45 AM
тАО03-09-2007 09:45 AM
Re: search command search-string - how search for '<char>' ?
computer programs? (You have some time to
think this over. I need to go to the local
Home Depot now to buy some hardware bolts and
hardware nuts.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 10:25 AM
тАО03-09-2007 10:25 AM
Re: search command search-string - how search for '<char>' ?
The text log file contains items such as
...A=''B''...
XYZ...B=''C''...
AABBCCDD...A=''D''...
where we must find two adjacent single quotes (apostrophes) a character and then two more adjacent single quotes.
search *.log "A=''D''"
%SEARCH-I-NOMATCHES, no strings matched
because of symbol substitution. I need to turn off symbol substitution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 10:56 AM
тАО03-09-2007 10:56 AM
Re: search command search-string - how search for '<char>' ?
...A=''B''...
XYZ...B=''C''...
AABBCCDD...A=''D''...
A = "B"
$ sea test.quot """B"""
A = "B"
$ sea test.quot "'"+"'B'"+"'"
...A=''B''...
XYZ...B=''C''...
AABBCCDD...A=''D''...
$
Because the fonts here display two single quotes as if it were a dowble quote, I have attached a text file you can view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 11:39 AM
тАО03-09-2007 11:39 AM
Re: search command search-string - how search for '<char>' ?
In other words, to search for all occurrences of two adjacent single quotes, use:
$ search file "'"+"'"
Since this font doesn't display well, that's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 12:06 PM
тАО03-09-2007 12:06 PM
Re: search command search-string - how search for '<char>' ?
The multiple strings that we think would be concatenated appear to be treated individually by search. I get false matches on unwanted lines in the file.
Next attempt:
I use /MATCH=AND to get what I want for now temporarily; but I am not yet understanding why the strings are not combined and treated as one search-string.
It appears that the DCL SEARCH command identically treats the commands
$ search test.quot "'"+"'B'"+"'"/match=and
and
$ search test.quot "'","'B'","'"/match=and
so I am assuming that string concatenation is NOT happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 12:55 PM
тАО03-09-2007 12:55 PM
Re: search command search-string - how search for '<char>' ?
$ text = "'" + "'%'" + "'"
$ sho symb text
TEXT = "''%''"
$ sea tmp.tmp &text/wild
The & forces 'deferred substitution'.
With PERL on any VMS version the single quotes are still nasty when expressed in a 'one liner'. So I would use 'octal' notation:
$ perl -ne "/\047\047.\047\047/" tmp.tmp
Now if you just want to match on say B and D, not C then change that to :
$ perl -ne "print if /\047\047[BD]\047\047/" tmp.tmp
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 01:29 PM
тАО03-09-2007 01:29 PM
Re: search command search-string - how search for '<char>' ?
We will be testing version 8.3 on Integrity soon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 02:07 PM
тАО03-09-2007 02:07 PM
Re: search command search-string - how search for '<char>' ?
and not just any single character, then "&"
seems to help:
alp $ ss = "'"+ "'"+ "d"+ "'"+ "'"
alp $ write sys$output ss
''d''
alp $ sea a*.txt &ss
******************************
ALP$DKA0:[SMS]APO.TXT;2
abc''d''efg
where:
alp $ type apo.txt
abcdefg
abc'defg
abcd'efg
abc'd'efg
abc'defg
abcd'efg
abc'd'efg
abc''defg
abcd''efg
abc'd''efg
abc''d'efg
abc''d''efg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 02:26 PM
тАО03-09-2007 02:26 PM
Solution$ x="**A**"
$ x[0,8]=%x27
$ x[8,8]=%x27
$ x[24,8]=%x27
$ x[32,8]=%x27
$ search y.y &x
....Z=''A''...
ABC=''A''...
$ type y.y
....Z=''A''...
...A=''B''...
XYZ...B=''C''...
AABBCCDD...A=''D''...
ABC=''A''...
$
Ampersand-based symbol substitution has been around only slightly less than forever. It's a second phase of substitution within the DCL parsing processing -- and you can get a double symbol substitution this way, if you need to do that. You can substitute a substring into a variable, then substitute the variable itself. This is one (very brute-force) way you can implement DCL arrays.
The 2nd edition of the Writing Real Programs in DCL book does cover ampersand-based substitution as it is one of the few ways to substitute symbols within the DCL command PIPE and its related processing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2007 05:24 PM
тАО03-09-2007 05:24 PM
Re: search command search-string - how search for '<char>' ?
It appears that the concatenation is being done by DCL, at a later stage than the CLI handling routines.
So it appears that Hein's example is about as short as is possible (that I know of).
If you need to search for a general string enclosed by two single quotes, you can set a temporary symbol using one of the methods mentioned, concatenating strings with single quotes, or overlaying an existing string with binary values as Hoff demonstrated. Once the string is in the symbol, using deferred substitution allows the symbol to escape the first pass substitution, but still be passed to the program as the "substituted" value.
For example to find
$ tmp = "'"+"'xyzzy'"+"'"
$ search file &tmp
By the way, the new feature Hein was referring to was the /WILD switch, not the "&" deferred substitution. He was saying that if you were always searching for two single quotes followed by a single character and then two more single quotes, you could use the % "match single character" wildcard along with the new /WILD switch (and the &) to do it.
As Hoff said, the & substitution has been around since very early days.
Try this:
$ a="&B" ! B must be uppercase
$ b="C" ! C must be uppercase
$ c="Hello"
$ write sys$output 'a
Hello
$
If you understand why that works, you will be well on your way to understanding DCL parsing.
P.S. I tend to avoid the use of & substitution because it is almost guaranteed to confuse the next person to visit the command procedure. There are also some seemingly arbitrary restrictions, for example the need for the symbols to be in uppercase. Try the above example with lowercase characters in the quotations, and you will see that it does not work.
However, there are cases where they are required, Hoff mentioned a few, and it seems to me that this is another case where they are necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2007 05:56 AM
тАО03-11-2007 05:56 AM
Re: search command search-string - how search for '<char>' ?
$ apost ="*"
$ apost[0,8] = %x27
$ string = apost + apost + "A" + apost + apost
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2007 05:14 PM
тАО03-11-2007 05:14 PM
Re: search command search-string - how search for '<char>' ?
Jim, as others pointed out, and the other examples make clear, the substitution feature has always been there.
The /WILD is newish, but since you did not indicate a specific version I though it was safe to assume you were running the current version. Reasonable? :^)
Anyway... the V8.3 Alpha SEARCH.EXE image runs just fine on a V7.2-1 Alpha. I tried.
Of course you need to provide the appropriate command definition which you can get from an 8.3 box with the VERB freeware, or find it attached here. I changed the original to point to image SEARCH_V83 to keep it clear and clean.
Finally, you did not react to the PERL suggestion. If you are really serious about searching for interesting pattern, than a langue providing REGULAR EXPRESSIONS is the way to go IMHO. For OpenVMS that would be PERL or AWK. Well worth the short learning curve. Not need to get all caried away with objects and methods, just exploit the basic tools like regexpr's.
Regards,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2007 11:02 PM
тАО03-11-2007 11:02 PM
Re: search command search-string - how search for '<char>' ?
The primary advantage of being able to do it in DCL is portability to other VMS systems that may or may not have other tools loaded.
The techniques discussed to allow DCL to set symbols with doubled single quotes is still useful however. Where I have used it is in command procedures that generate other command procedures, where the generated command procedure has a line like
$ mail nla0: "''notify'" /subject="Entry ''this_entry' starting ''this_proc'"
The generating command procedure would have a line like:
$ write outproc "$ mail nla0: ""'"+"'notify'"" /subject=""Entry '"+ -
"'this_entry' starting '"+"'this_proc'"""
P.S. Hein, I don't know how to do the following with regex:
$ seach file a,b,c,d,e/match=and
without testing for each permutation of ordering. Am I missing something simple?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2007 11:16 PM
тАО03-11-2007 11:16 PM
Re: search command search-string - how search for '<char>' ?
http://h71000.www7.hp.com/freeware/freeware70/find/
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2007 11:23 PM
тАО03-11-2007 11:23 PM
Re: search command search-string - how search for '<char>' ?
>> without testing for each permutation of >> ordering. Am I missing something simple?
regular expressions are 'pattern matches', not the dcl searched.
So I'm afraid you need to either do the permutations if practical or combine them. For example:
/a/ && /b/ && /c/ && /d/ && print
fwiw.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 01:19 AM
тАО03-12-2007 01:19 AM
Re: search command search-string - how search for '<char>' ?
$ sea sys$login:login.com b,c,x,p,g,2/mat=and
$ mgbook4 :== $utility:mgbook disk$axpdocsep962:[decw$book]*lib*/sh
$ awk "/b/ && /c/ && /x/ && /p/ && /g/ && /2/ { print }" sys$login:login.com
$ mgbook4 :== $utility:mgbook disk$axpdocsep962:[decw$book]*lib*/sh
$
I was under the mistaken impression that only one pattern was allowed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 01:21 AM
тАО03-12-2007 01:21 AM
Re: search command search-string - how search for '<char>' ?
perl -ne "print if m('\'D'\')" tmp.tmp
Still a bit messy, but easier than using octal escapes.
[The qq() and q() notation can also be useful in VMS one-liners]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2007 12:53 PM
тАО03-13-2007 12:53 PM
Re: search command search-string - how search for '<char>' ?
I am not yet a PERL user. (One of these days.)
I have been around since VMS v3 and have forgotten about using & in such a way.
I do so much database work with PL/SQL I sometimes forget some DCL basics.
We have some 7.1-2 customers, 7.2-1, 7.3, 7.3-1 etc. but we use 8.2 and just installed 8.3 on Integrity.
Thank you one and all.