- 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-11-2006 08:25 PM
тАО01-11-2006 08:25 PM
Re: How to extract string from command output?
Thanks a million for your explanation. I now understand how to extract the strings.
Basically, i can get an output from my command and perform a search followed by a f$element function to extract the string.
However, is there any command or method to extract by line number?
Let's say for example, i would like to extract only line 1 of textfile A and line 2 onwards of textfile B. Finally join them into a new textfile.
The way i see f$element is extracting strings by a seperator character or element.
Please kindly advice. Thank you!
Andrew
____________________________________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 08:32 PM
тАО01-11-2006 08:32 PM
Re: How to extract string from command output?
What are the workings beneath the 'tt'?
I can't run this in script mode. I'll have to execute it manually to obtain the output.
Andrew
____________________________________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 09:00 PM
тАО01-11-2006 09:00 PM
Re: How to extract string from command output?
There is a freeware utility called EXTRACT which allows to extract selectable record from files, see http://vms.process.com/scripts/fileserv/fileserv_search.exe?package=extract&description=&author=&system=Either&language=All&RD=&RM=&RY=
regards kalle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 09:30 PM
тАО01-11-2006 09:30 PM
Re: How to extract string from command output?
$ @TT:
Is running a script from your terminal.
/OUTPUT redefines SYS$OUTPUT
The following will redirect output for one command then return to normal.
$ DEFINE/USER SYS$OUTPUT FILE.LIS
$ somecommandhere
Then open the file
$ OPEN HANDLE FILE.LIS
read the lines
$ READ HANDLE LINE
and process them.
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 10:13 PM
тАО01-11-2006 10:13 PM
Re: How to extract string from command output?
Does the extract utility helps me in extracting particular lines from a textfile?
I'm unable to d/l the zip file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 10:36 PM
тАО01-11-2006 10:36 PM
Re: How to extract string from command output?
Here are the Examples from HELP:
2 examples
!Display the last 10 lines of Login.Com on the terminal
$ EXTRACT/TAIL=10 Login.Com /IDENTIFY
!Look at the first few lines of all Fortran source files
$ EXTRACT/HEAD=5 *.For
!Copy Test.Txt to Test.Dat, converting text into upper case
! and removing excess blanks.
$ EXTRACT/EDIT=(UPCASE,COMPRESS) Test.Txt/OUTPUT=Test.Dat
!Extract all but the first 10 and last 10 records of Test.Dat
$ EXTRACT Test.Dat/RECORDS=(START=11,END=-11) /OUTPUT=Test.Mid
!Get specific columns out of several files
$ EXTRACT/COLUMNS=(1:10,18:19,25,41:*) Test.*,[...]*.Tmp
I've added the ZIP file
regards Kalle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2006 11:40 PM
тАО01-11-2006 11:40 PM
Re: How to extract string from command output?
>> Let's say for example, i would like to extract only line 1 of textfile A and line 2 onwards of textfile B. Finally join them into a new textfile.
Sure, same loop through file principle, but keep a running count... in general. However, in the case of 1 or 2, I would just read it.
Untested example below.
Sounds like you'd better get that 'Programming in DCL book' and check out some examples, on your system or here in the forum.
However, since you are new to VMS/DCL I would suggest to learn PERL and/or AWK for file/line/text manipulation. You'll be able to use the skill on multiple platforms
$close/nolog file ! In case it was left open
$open file file-1
$n=6
$i=0
$loop:
$1=1+1
$read /end=not_found file record
$if i.lt.n then goto loop
$
$write sys$output "record ''n' = record"
Your question
$close/nolog file ! In case it was left open
$open file file-1
$read /end=not_found file record_1
$close file
$open file file-1
$read /end=not_found file record_2
$read /end=not_found file record_2
$close file
$open/write file file-3
$write file record_1 + record_2
$close file
to read record 123 in perl:
perl -ne "print if ($.== 123)"
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2006 05:41 AM
тАО01-12-2006 05:41 AM
Re: How to extract string from command output?
another wat to generate output from a command procedure, say ABCD.COM
$ @ABCD/OUTPUT=
Remember to put /out BEFORE any params.
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2006 12:21 AM
тАО01-17-2006 12:21 AM
Re: How to extract string from command output?
============================================
$ IF (MAINfreebytes .LES. INTfilesize) .OR. (VSMfreebytes .LES. PATfilesize)
$ THEN GOTO ERROR34
$ ELSE write temp "Free space check OK."
$ ENDIF
============================================
MAIN Memory free space: 2790400 bytes
VSM Memory free space: 59935744 bytes
Program file size: 91136 bytes
Pattern files size: 14043136 bytes
Insufficient tester memory space!
But the result was incorrect! This is so strange! I even explicitly defined them to be of integer type.
E.g.
$ INTfilesize = f$integer(f$element(4," ",record))
Can anyone advice on what is wrong here?
Thanks!
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2006 12:28 AM
тАО01-17-2006 12:28 AM
Re: How to extract string from command output?
i was comparing the following:
$ IF (2790400 .LES. 91136) .AND. (59935744 .LES. 14043136)
$ THEN write sys$output "Insufficient tester memory space!"
$ ELSE write temp "Free space check OK."
$ ENDIF
============================================
Result: Insufficient tester memory space!
I was expecting to see "Free space check OK."