<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to extract string from command output? in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703190#M33346</link>
    <description>Andrew,&lt;BR /&gt;&lt;BR /&gt;$STATUS = %X1  (or zero-filled: %X00000001 ) is the "normal"status for any command, it means "successfully finished without any comments"&lt;BR /&gt;&lt;BR /&gt;ANY other odd numeric status is qualified success ( in case of search: the SEARCH did not encounter any error, it reached the end of file(s) to search, BUT did not find any hits )&lt;BR /&gt;Bits 0-3 code the $severity of the message:&lt;BR /&gt;0 = Warning&lt;BR /&gt;1 = Success&lt;BR /&gt;2 = Error&lt;BR /&gt;3 = Qualified Success&lt;BR /&gt;4 = Fatal &lt;BR /&gt;&lt;BR /&gt;There are potentially 2**32-1 different statusses, so pretty much any condition can have its own status.&lt;BR /&gt;Those numbers are segmentised:&lt;BR /&gt;0 - 2**16 -1 (16 bits) are "reserved to Digital. &lt;BR /&gt;Then some (4 I think) code for the Facility.&lt;BR /&gt;All others are available, and can be licensed, by 3rd party.&lt;BR /&gt;&lt;BR /&gt;In sys$message there are several modules that "know the accompanying text and how to present it"&lt;BR /&gt;Any 3rd party reserving a range also adds a module.&lt;BR /&gt;&lt;BR /&gt;And it is the responsibility of the (OS-) coders that ANY condition gets its own status, AND those statusses are represented by the MESSAGE servers.&lt;BR /&gt;&lt;BR /&gt;This way VMS does not have the VERY helpful "General Failure" or "An error has occurred" messages. GREAT in tracing trouble!&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;&lt;BR /&gt;Proost.&lt;BR /&gt;&lt;BR /&gt;Have one on me.&lt;BR /&gt;&lt;BR /&gt;jpe&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 25 Jan 2006 08:23:48 GMT</pubDate>
    <dc:creator>Jan van den Ende</dc:creator>
    <dc:date>2006-01-25T08:23:48Z</dc:date>
    <item>
      <title>How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703160#M33316</link>
      <description>Hi Gurus,&lt;BR /&gt;&lt;BR /&gt;I'm using a OVMS v5.5 and i'm trying to extract a particular string and word from a command output, for example:&lt;BR /&gt;==============================================&lt;BR /&gt;$ mem dis /int&lt;BR /&gt;Programs in 68040 Main Memory&lt;BR /&gt;&lt;BR /&gt;  File name        Id  Type  Status&lt;BR /&gt;  ---------        --  ----  ------&lt;BR /&gt;  P2780232N111AC1.INT&lt;BR /&gt;                    2  sum3  used&lt;BR /&gt;  P1TD703130K10A4.INT&lt;BR /&gt;                    1  sum3&lt;BR /&gt;  LIANG.INT         6  sum3  used&lt;BR /&gt;&lt;BR /&gt;  Total 3 files 380928 bytes. 2409472 bytes free.&lt;BR /&gt;$&lt;BR /&gt;==============================================&lt;BR /&gt;&lt;BR /&gt;Now, how do i extract the free bytes information from the above output. In unix scripting, i would usually use the grep function. Can anyone offer help? Thanks!&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;&lt;BR /&gt;Andrew&lt;BR /&gt;______________________________________________</description>
      <pubDate>Thu, 05 Jan 2006 03:54:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703160#M33316</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-05T03:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703161#M33317</link>
      <description>Use this as an example.&lt;BR /&gt;&lt;BR /&gt;$ define/us sys$output 'ct_workf'&lt;BR /&gt;$ show proc/mem&lt;BR /&gt;$ open/read x 'ct_workf'&lt;BR /&gt;$r30:&lt;BR /&gt;$ read/end=e30 x x_rcd&lt;BR /&gt;$ x_rcd=f$ed(x_rcd,"compress")&lt;BR /&gt;$ pos=f$loc("Free Space (bytes)",x_rcd)&lt;BR /&gt;$ if pos .ne. f$len(x_rcd)&lt;BR /&gt;$ then&lt;BR /&gt;$    cur=f$int(f$elem(4," ",x_rcd))&lt;BR /&gt;$    if cur .ne. prevcur then d "Current free space : ''cur'"&lt;BR /&gt;$    prevcur==cur&lt;BR /&gt;$    if cur .le. 5000 then say "''CUR' free bytes process dynamic memory"&lt;BR /&gt;$ endif&lt;BR /&gt;$ goto r30&lt;BR /&gt;$e30:&lt;BR /&gt;$ close x&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2006 04:28:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703161#M33317</guid>
      <dc:creator>Wim Van den Wyngaert</dc:creator>
      <dc:date>2006-01-05T04:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703162#M33318</link>
      <description>Hi Wim, &lt;BR /&gt;Thanks for your post, but do you have a simplier explanation for your example? I don't understand it very well. I'm pretty new to OVMS. Thanks!</description>
      <pubDate>Thu, 05 Jan 2006 07:23:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703162#M33318</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-05T07:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703163#M33319</link>
      <description>Hello Andrew, welcome to the OpenVMS group.&lt;BR /&gt;&lt;BR /&gt;In Wim's example he solves a much similar problem, and leaves it up to you to translate to your exact needs. I encourage you to study it and learn. The main 'trick' he uses, is a classic DCL scripting technique of searching for a substring. This returns the string length if not found.&lt;BR /&gt;&lt;BR /&gt;Here is a solution taylored to your case where i start by loooking for an element, splitting the line by spaces. Compare the  f$elem(7," ",record) with $7 in AWK.&lt;BR /&gt;P1 is the name of a file (SYS$PIPE if needed,&lt;BR /&gt;&lt;BR /&gt;$close/nolog file ! In case it was left open&lt;BR /&gt;$open file 'p1&lt;BR /&gt;$loop:&lt;BR /&gt;$read /end=not_found file record&lt;BR /&gt;$if f$elem(7," ",record).NES."bytes" THEN GOTO loop&lt;BR /&gt;$if f$elem(8," ",record).NES."free." THEN GOTO loop&lt;BR /&gt;$bytes = f$elem(6," ",record)&lt;BR /&gt;$SHOW SYMBOL bytes&lt;BR /&gt;$CLOSE file&lt;BR /&gt;$EXIT&lt;BR /&gt;$not_found:&lt;BR /&gt;$WRITE SYS$OUTPUT "line with free bytes not recognized"&lt;BR /&gt;$CLOSE file&lt;BR /&gt;&lt;BR /&gt;Be sure to read the fine HELP LEXICAL and help in genral, and try to get a 'programming in DCL' book in print.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now 5.5 is a terribly old VMS version. I don;t suppose there is any hope to upgrade that?&lt;BR /&gt;Can you get PERL for 5.5?&lt;BR /&gt;If so, the solution of course can become nuch more like Unix:&lt;BR /&gt;&lt;BR /&gt;$ perl -ne "print $1 if /(\d+)\s+bytes free.$/" tmp.tmp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jan 2006 07:46:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703163#M33319</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-01-05T07:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703164#M33320</link>
      <description>Andrew,&lt;BR /&gt;&lt;BR /&gt;Basically, the script that Wlm posted scans the output one line at a time, looking for the string "Free Space (bytes)", and then extracting the information from the line. The output is re-routed from the standard output device, by default the terminal, to a scratch file contained in the variable "ct-workf". The command SHOW MEMORY is used to generate the output information to parse.&lt;BR /&gt;&lt;BR /&gt;The processing and analysis of the lines is done using DCL lexical functions. These are documented in the DCL Dictionary (the documentation for the recent releases in available in PDF and HTML versions on the OpenVMS www site at &lt;A href="http://www.hp.com/go/opemvms;" target="_blank"&gt;http://www.hp.com/go/opemvms;&lt;/A&gt; while some new functions, and options have been added since 5.5, the manual is still usable; the information is also available online by using the command HELP LEXICAL).&lt;BR /&gt;&lt;BR /&gt;I also did a presentation on the basics of DCL scripting at the Fall 1995 DECUS Symposium, you can get the slides from that session via &lt;A href="http://www.rlgsc.com/decus/usf95/index.html)." target="_blank"&gt;http://www.rlgsc.com/decus/usf95/index.html).&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;</description>
      <pubDate>Thu, 05 Jan 2006 07:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703164#M33320</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2006-01-05T07:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703165#M33321</link>
      <description>Andrew&lt;BR /&gt;&lt;BR /&gt;Other solution is use pipe and search commands.&lt;BR /&gt;For example:&lt;BR /&gt;PIPE SHO PROC/MEM | SEAR SYS$INPUT "Free Space"&lt;BR /&gt;&lt;BR /&gt;Happy new year.&lt;BR /&gt;Saludos.&lt;BR /&gt;Daniel.</description>
      <pubDate>Mon, 09 Jan 2006 04:45:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703165#M33321</guid>
      <dc:creator>Daniel Fernandez Illan</dc:creator>
      <dc:date>2006-01-09T04:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703166#M33322</link>
      <description>Daniel,&lt;BR /&gt;&lt;BR /&gt;look at the original question: VMS V5.5&lt;BR /&gt;&lt;BR /&gt;That does not yet support PIPE.&lt;BR /&gt;&lt;BR /&gt;Proost.&lt;BR /&gt;&lt;BR /&gt;Have one on me.&lt;BR /&gt;&lt;BR /&gt;jpe</description>
      <pubDate>Mon, 09 Jan 2006 05:09:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703166#M33322</guid>
      <dc:creator>Jan van den Ende</dc:creator>
      <dc:date>2006-01-09T05:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703167#M33323</link>
      <description>Sorry Jan&lt;BR /&gt;I am landing from my vacations (much beer and wine) and I am still slept.&lt;BR /&gt;&lt;BR /&gt;Sorry.&lt;BR /&gt;Saludos.&lt;BR /&gt;Daniel.</description>
      <pubDate>Mon, 09 Jan 2006 05:21:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703167#M33323</guid>
      <dc:creator>Daniel Fernandez Illan</dc:creator>
      <dc:date>2006-01-09T05:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703168#M33324</link>
      <description>Other solution without use PIPE&lt;BR /&gt;&lt;BR /&gt;$DEFINE SYS$OUTPUT MEMO.TXT&lt;BR /&gt;$SHO PROC/MEM&lt;BR /&gt;$DEASS SYS$OUTPUT&lt;BR /&gt;$SEAR MEMO.TXT "Free Space"&lt;BR /&gt;$DELE MEMO.TXT.*&lt;BR /&gt;&lt;BR /&gt;Saludos.&lt;BR /&gt;Daniel.</description>
      <pubDate>Wed, 11 Jan 2006 14:09:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703168#M33324</guid>
      <dc:creator>Daniel Fernandez Illan</dc:creator>
      <dc:date>2006-01-11T14:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703169#M33325</link>
      <description>Before there was pipe, I used @tt (undocumented) to redirect output&lt;BR /&gt;for example&lt;BR /&gt;&lt;BR /&gt;$@tt /out=out.txt&lt;BR /&gt;$mem dis /int&lt;BR /&gt;$exit&lt;BR /&gt;$search out.txt "bytes free" /out=line.txt&lt;BR /&gt;&lt;BR /&gt;line.txt then contains the total line&lt;BR /&gt;you can open and read the file into a symbol&lt;BR /&gt;and then use f$locate and f$extract to get your integer.&lt;BR /&gt;Phil&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jan 2006 00:48:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703169#M33325</guid>
      <dc:creator>Phil.Howell</dc:creator>
      <dc:date>2006-01-12T00:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703170#M33326</link>
      <description>Hello Hein,&lt;BR /&gt;&lt;BR /&gt;Thanks a million for your explanation. I now understand how to extract the strings.&lt;BR /&gt;&lt;BR /&gt;Basically, i can get an output from my command and perform a search followed by a f$element function to extract the string.&lt;BR /&gt;&lt;BR /&gt;However, is there any command or method to extract by line number?&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;The way i see f$element is extracting strings by a seperator character or element.&lt;BR /&gt;&lt;BR /&gt;Please kindly advice. Thank you!&lt;BR /&gt;&lt;BR /&gt;Andrew&lt;BR /&gt;____________________________________________</description>
      <pubDate>Thu, 12 Jan 2006 04:25:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703170#M33326</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-12T04:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703171#M33327</link>
      <description>Hi Phil,&lt;BR /&gt;&lt;BR /&gt;What are the workings beneath the 'tt'?&lt;BR /&gt;I can't run this in script mode. I'll have to execute it manually to obtain the output.&lt;BR /&gt;&lt;BR /&gt;Andrew&lt;BR /&gt;____________________________________________</description>
      <pubDate>Thu, 12 Jan 2006 04:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703171#M33327</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-12T04:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703172#M33328</link>
      <description>The @ starts the commandfile TT, which is a logical name pointing to your terminal, but it allows for the /OUPUT qualifier.&lt;BR /&gt;&lt;BR /&gt;There is a freeware utility called EXTRACT which allows to extract selectable record from files, see &lt;A href="http://vms.process.com/scripts/fileserv/fileserv_search.exe?package=extract&amp;amp;description=&amp;amp;author=&amp;amp;system=Either&amp;amp;language=All&amp;amp;RD=&amp;amp;RM=&amp;amp;RY=" target="_blank"&gt;http://vms.process.com/scripts/fileserv/fileserv_search.exe?package=extract&amp;amp;description=&amp;amp;author=&amp;amp;system=Either&amp;amp;language=All&amp;amp;RD=&amp;amp;RM=&amp;amp;RY=&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;regards kalle</description>
      <pubDate>Thu, 12 Jan 2006 05:00:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703172#M33328</guid>
      <dc:creator>Karl Rohwedder</dc:creator>
      <dc:date>2006-01-12T05:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703173#M33329</link>
      <description>TT is a logical name refering to your terminal.&lt;BR /&gt;$ @TT:&lt;BR /&gt;&lt;BR /&gt;Is running a script from your terminal.&lt;BR /&gt;&lt;BR /&gt;/OUTPUT redefines SYS$OUTPUT &lt;BR /&gt;&lt;BR /&gt;The following will redirect output for one command then return to normal.&lt;BR /&gt;&lt;BR /&gt;$ DEFINE/USER SYS$OUTPUT FILE.LIS&lt;BR /&gt;$ somecommandhere&lt;BR /&gt;Then open the file&lt;BR /&gt;$ OPEN HANDLE FILE.LIS&lt;BR /&gt;read the lines&lt;BR /&gt;$ READ HANDLE LINE&lt;BR /&gt;and process them.</description>
      <pubDate>Thu, 12 Jan 2006 05:30:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703173#M33329</guid>
      <dc:creator>Ian Miller.</dc:creator>
      <dc:date>2006-01-12T05:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703174#M33330</link>
      <description>Hi Kalle,&lt;BR /&gt;&lt;BR /&gt;Does the extract utility helps me in extracting particular lines from a textfile?&lt;BR /&gt;&lt;BR /&gt;I'm unable to d/l the zip file.</description>
      <pubDate>Thu, 12 Jan 2006 06:13:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703174#M33330</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-12T06:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703175#M33331</link>
      <description>It allows specification of start/end records, start/end columns and can edit the extracted records (like F$EDIT, but more).&lt;BR /&gt;&lt;BR /&gt;Here are the Examples from HELP:&lt;BR /&gt;&lt;BR /&gt;2 examples&lt;BR /&gt;  !Display the last 10 lines of Login.Com on the terminal&lt;BR /&gt;  $ EXTRACT/TAIL=10 Login.Com /IDENTIFY&lt;BR /&gt;&lt;BR /&gt;  !Look at the first few lines of all Fortran source files&lt;BR /&gt;  $ EXTRACT/HEAD=5 *.For&lt;BR /&gt;&lt;BR /&gt;  !Copy Test.Txt to Test.Dat, converting text into upper case&lt;BR /&gt;  !  and removing excess blanks.&lt;BR /&gt;  $ EXTRACT/EDIT=(UPCASE,COMPRESS) Test.Txt/OUTPUT=Test.Dat&lt;BR /&gt;&lt;BR /&gt;  !Extract all but the first 10 and last 10 records of Test.Dat&lt;BR /&gt;  $ EXTRACT Test.Dat/RECORDS=(START=11,END=-11) /OUTPUT=Test.Mid&lt;BR /&gt;&lt;BR /&gt;  !Get specific columns out of several files&lt;BR /&gt;  $ EXTRACT/COLUMNS=(1:10,18:19,25,41:*) Test.*,[...]*.Tmp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I've added the ZIP file&lt;BR /&gt;&lt;BR /&gt;regards Kalle</description>
      <pubDate>Thu, 12 Jan 2006 06:36:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703175#M33331</guid>
      <dc:creator>Karl Rohwedder</dc:creator>
      <dc:date>2006-01-12T06:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703176#M33332</link>
      <description>&amp;gt;&amp;gt;  However, is there any command or method to extract by line number?&lt;BR /&gt;&amp;gt;&amp;gt; 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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;Untested example below.&lt;BR /&gt;&lt;BR /&gt;Sounds like you'd better get that 'Programming in DCL book' and   check out some examples, on your system or here in the forum.&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;$close/nolog file ! In case it was left open&lt;BR /&gt;$open file file-1&lt;BR /&gt;$n=6&lt;BR /&gt;$i=0&lt;BR /&gt;$loop:&lt;BR /&gt;$1=1+1&lt;BR /&gt;$read /end=not_found file record&lt;BR /&gt;$if i.lt.n then goto loop&lt;BR /&gt;$&lt;BR /&gt;$write sys$output "record ''n' = record"&lt;BR /&gt;&lt;BR /&gt;Your question&lt;BR /&gt;&lt;BR /&gt;$close/nolog file ! In case it was left open&lt;BR /&gt;$open file file-1&lt;BR /&gt;$read /end=not_found file record_1&lt;BR /&gt;$close file&lt;BR /&gt;$open file file-1&lt;BR /&gt;$read /end=not_found file record_2&lt;BR /&gt;$read /end=not_found file record_2&lt;BR /&gt;$close file&lt;BR /&gt;$open/write file file-3&lt;BR /&gt;$write file record_1 + record_2&lt;BR /&gt;$close file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;to read record 123 in perl:&lt;BR /&gt;&lt;BR /&gt;perl -ne "print if ($.== 123)"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jan 2006 07:40:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703176#M33332</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-01-12T07:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703177#M33333</link>
      <description>Andrew,&lt;BR /&gt;&lt;BR /&gt;another wat to generate output from a command procedure, say ABCD.COM&lt;BR /&gt;&lt;BR /&gt;$ @ABCD/OUTPUT=&lt;SOMEFILE&gt;  [p1] [p2] ...&lt;BR /&gt;&lt;BR /&gt;Remember to put /out  BEFORE any params.&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;&lt;BR /&gt;Proost.&lt;BR /&gt;&lt;BR /&gt;Have one on me.&lt;BR /&gt;&lt;BR /&gt;jpe&lt;/SOMEFILE&gt;</description>
      <pubDate>Thu, 12 Jan 2006 13:41:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703177#M33333</guid>
      <dc:creator>Jan van den Ende</dc:creator>
      <dc:date>2006-01-12T13:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703178#M33334</link>
      <description>I had extracted the numbers (free space) from the command output and made some logical comparison between them.&lt;BR /&gt;&lt;BR /&gt;============================================&lt;BR /&gt;$ IF (MAINfreebytes .LES. INTfilesize) .OR. (VSMfreebytes .LES. PATfilesize)&lt;BR /&gt;$ THEN GOTO ERROR34&lt;BR /&gt;$ ELSE write temp "Free space check OK."&lt;BR /&gt;$ ENDIF&lt;BR /&gt;============================================&lt;BR /&gt;&lt;BR /&gt;MAIN Memory free space: 2790400 bytes&lt;BR /&gt;VSM Memory free space: 59935744 bytes&lt;BR /&gt;Program file size: 91136 bytes&lt;BR /&gt;Pattern files size: 14043136 bytes&lt;BR /&gt;Insufficient tester memory space!&lt;BR /&gt;&lt;BR /&gt;But the result was incorrect! This is so strange! I even explicitly defined them to be of integer type.&lt;BR /&gt;&lt;BR /&gt;E.g.&lt;BR /&gt;$ INTfilesize = f$integer(f$element(4," ",record))&lt;BR /&gt;&lt;BR /&gt;Can anyone advice on what is wrong here?&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Andrew</description>
      <pubDate>Tue, 17 Jan 2006 08:21:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703178#M33334</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-17T08:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract string from command output?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703179#M33335</link>
      <description>Sorry, i wasn't very clear in my previous post.&lt;BR /&gt;&lt;BR /&gt;i was comparing the following:&lt;BR /&gt;&lt;BR /&gt;$ IF (2790400 .LES. 91136) .AND. (59935744 .LES. 14043136) &lt;BR /&gt;$ THEN write sys$output "Insufficient tester memory space!"&lt;BR /&gt;$ ELSE write temp "Free space check OK." &lt;BR /&gt;$ ENDIF &lt;BR /&gt;============================================&lt;BR /&gt;Result: Insufficient tester memory space!&lt;BR /&gt;&lt;BR /&gt;I was expecting to see "Free space check OK."&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jan 2006 08:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-to-extract-string-from-command-output/m-p/3703179#M33335</guid>
      <dc:creator>Andrew Yip</dc:creator>
      <dc:date>2006-01-17T08:28:47Z</dc:date>
    </item>
  </channel>
</rss>

