- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: How to extract string from command output?
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
тАО01-17-2006 12:51 AM
тАО01-17-2006 12:51 AM
Re: How to extract string from command output?
.LE. 4 Arithmetic less than or equal
.LES. 4 String less than or equal
Try replacing .LES. with .LE. when working with numbers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2006 01:35 AM
тАО01-17-2006 01:35 AM
Re: How to extract string from command output?
On the risk of being superfluous, some more explicit explanation of Duncans answer:
If you compare the STRING 5 with 123456, then it compares the first character of both, if equal the next char, etc, until a difference is found. And since "5" is greater than "1", so the string "5" is considered greater than "12345".
Sorry if this was already clear.
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 11:43 PM
тАО01-23-2006 11:43 PM
Re: How to extract string from command output?
Oops! Thanks for spotting the mistake.
I now realized using the wrong operator.
It works now. =)
By the way, if i were to search a file for a particular string and the result is negative, how do i get the empty result or status or whatever which i can work on?
E.g.
$ search temp.txt ABC /output=line.txt
%SEARCH-I-NOMATCHES, no strings matched
I need the result to perform some work. However if the search result is positive, at least i have something to retrieve from the 'line.txt' file to perform some work.
Is there any work-around solution to this?
Please advice, anyone. Thanks a million!
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2006 12:18 AM
тАО01-24-2006 12:18 AM
Re: How to extract string from command output?
your easiest pathway to achieve that is to do any search that results in "no strings matched".
_DIRECTLY_ after that do a
$ show symbol $status
Pick up the result and paste it into your command file.
In your command file, if for some reason it is undesirable or impossible to IMMEDIATELY act upon $STATUS, then start by saving it in another symbol, and use that later on.
Take care, the value of $status actually is in STRING format, so you need the string comparison operators.
Success.
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2006 12:21 AM
тАО01-24-2006 12:21 AM
Re: How to extract string from command output?
The search command still generates a file, an emtpy one. From Wim's first post of code, the first read will result in an end-of-file detection and therefore the code will jump to e30: label.
If you want to do something else you could check the $severity level returned from the search command:
For %SEARCH-I-NOMATCHES, no strings matched
$SEVERITY == "3"
for matches
$SEVERITY == "1",
so after the search command line you could add $ IF $SEVERITY .EQS. "3" THEN ...
If course $STATUS could also be used and checked. ($SEVERITY and $STATUS return information about the previous DCL command executed, ie their level of success and return code, try typing $ write sys$output f$message($status) after entering an invalid dcl command)
Also, you could add the qualifer /NOWARNINGS to the search command to hide the "%SEARCH-I-NOMATCHES, no strings matched" message from appearing.
Kind Regards
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2006 02:46 AM
тАО01-24-2006 02:46 AM
Re: How to extract string from command output?
Maybe it is time to review the task you are trying to accomplish and perhaps provide a sample input file, appended as .TXT to a reply.
The VMS SEARCH tool would be good to select a few lines to a new /intermediate output file.
But it looks like you needs data from several lines, and interpret each line.
In that case I would just read teh whole file with DCL and pick and choose as you go.
Then again, I would not really do that in DCL but in PERL instead.
Based on the text line presented earlier i would write a perl program like:
--- freespace.pl ------
while (<>) {
$main = $1 if /MAIN Memory.*\s(\d+)/;
$VSM = $1 if /Memory free.*\s(\d+)/;
$int = $1 if /Program fil.*\s(\d+)/;
$pat = $1 if /Pattern fil.*\s(\d+)/;
}
$problem .= " Main" if ($main < $int);
$problem .= " Pattern" if ($VSM < $pat);
$ENV{freespace} = $problem;
--------------------
And I would use it in a DCL procedure like:
$PERL freespace.pl your-file.txt
$IF F$TRNLNM("freespace").NES.""
$THEN
$ WRITE SYS$OUTPUT "Insufficient tester memory space! (", F$TRNLNM("freespace"), ")"
$ GOTO ERROR34
$ ELSE write temp "Free space check OK."
$ ENDIF
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2006 07:48 AM
тАО01-24-2006 07:48 AM
Re: How to extract string from command output?
This example shows how to get the begin and end dates for an errorlog file into a logical name and then into a symbol:
$ SUMMARIZE = "DIAGNOSE/TRANSLATE/SUMMARY"
$ pipe summarize 'errlog_file' | search sys$input 'date_string' | -
( read sys$pipe d1 ; read sys$pipe d2 ; -
ds=""""+f$ele(dtelem," ",f$edi(d1,"TRIM,COMPRESS"))+","+f$ele(dtelem," ",f$edi(d2,"TRIM,COMPRESS"))+"""" ; -
define/job errdates &ds )
$SYMBOL_ASSIGN:
$ errdates = F$trnlnm("ERRDATES")
$ deassign/job ERRDATES
$ 'start_symbol' == f$element(0,",",errdates)
$ 'end_symbol' == f$element(1,",",errdates)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2006 11:58 PM
тАО01-24-2006 11:58 PM
Re: How to extract string from command output?
Thanks a million!
Your suggestions solves my problem.
It's a pretty good and fast idea.
But, by the way, out of curiousity, does the $status: "%X00000001" & "%X08D78053" mean anything specifically besides 'found' & 'not found'?
=)
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2006 12:04 AM
тАО01-25-2006 12:04 AM
Re: How to extract string from command output?
Thanks for your help & advice rendered earlier in this post, and thanks for promoting Perl too.
As much as i would like to pick up Perl, but i have limited time and resources to do so now.
Very much for now, i'm pretty stuck with using OVMS to deal with some modifications on my existing scripts. =(
But anyway, you guys are real great! Couldn't have done it without all of you!
You guys made my day!
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2006 12:18 AM
тАО01-25-2006 12:18 AM
Re: How to extract string from command output?
Though Kalle had earlier suggested to use the EXTRACT utility, but i'm sorry i hadn't really tried it out yet.
But anyway, i stumbled upon the open/read/write command which claims to be able to open a file and write records at the beginning of the file, as compared to EOF for the open/append command.
However, when i tried to use this, i was given an error which i believe i must have done it wrongly. Stupid me!
What's the correct way to use the open/read/write command?