<?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: Extracting a specific string in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263142#M40784</link>
    <description>Done</description>
    <pubDate>Wed, 17 Nov 2010 16:08:49 GMT</pubDate>
    <dc:creator>Marcos Llano</dc:creator>
    <dc:date>2010-11-17T16:08:49Z</dc:date>
    <item>
      <title>Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263137#M40779</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm looking to extract and specific string from a file. Basically, first I execute a ping to a host (before will be 20) that the result go to a file.&lt;BR /&gt;Then, a job try to search what % of packets have lost. Well, with the lexical F$EXTRACT and F$LOCATE I can only print "0% packet loss" but putting a lot of condicionals, and I don't like much this metod. How could I extract only the 0% (or 100%)? With this value&lt;BR /&gt;&lt;BR /&gt;Thanks and regards</description>
      <pubDate>Wed, 17 Nov 2010 15:12:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263137#M40779</guid>
      <dc:creator>Marcos Llano</dc:creator>
      <dc:date>2010-11-17T15:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263138#M40780</link>
      <description>If I understand your requirements correctly, you wish to extract the percentage loss only.  If that is the case, use the F$locate looking for "received," and then for the string "% packet" and extract the characters  between those positions.  Use the f$integer to change to a value.&lt;BR /&gt;&lt;BR /&gt;Dan</description>
      <pubDate>Wed, 17 Nov 2010 15:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263138#M40780</guid>
      <dc:creator>abrsvc</dc:creator>
      <dc:date>2010-11-17T15:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263139#M40781</link>
      <description>If the variable line contains&lt;BR /&gt;"4 packets transmitted, 4 packets received, 0% packet loss"&lt;BR /&gt;&lt;BR /&gt;Then parse it like:&lt;BR /&gt;line=f$edit(line,"TRIM,COMPRESS")&lt;BR /&gt;rest=f$edit(f$element(2,",",line),"TRIM")&lt;BR /&gt;perc=f$element(0," ",rest)&lt;BR /&gt;show sym perc&lt;BR /&gt;&lt;BR /&gt;I broke it into several stements for clarity, You can put everything into a single f$element(...) statement.</description>
      <pubDate>Wed, 17 Nov 2010 15:40:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263139#M40781</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2010-11-17T15:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263140#M40782</link>
      <description>There are source code versions of ping around, and you can tweak one to meet your needs.  &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.ping127001.com/pingpage.htm" target="_blank"&gt;http://www.ping127001.com/pingpage.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.cs.utah.edu/~swalton/listings/sockets/programs/part4/chap18/ping.c" target="_blank"&gt;http://www.cs.utah.edu/~swalton/listings/sockets/programs/part4/chap18/ping.c&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;There's a callable ping tool on Freeware V8.0.&lt;BR /&gt;&lt;BR /&gt;There are also free and commercial services around such as the pingdom service, and any number of monitoring tools such as nagios nrpe that can be used to monitor uptime.</description>
      <pubDate>Wed, 17 Nov 2010 16:04:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263140#M40782</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2010-11-17T16:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263141#M40783</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;A lot of thanks Joseph and abrsvc. I have exactly that i wanted&lt;BR /&gt;&lt;BR /&gt;$ OPEN IN OPER00DIR:PING.DAT&lt;BR /&gt;$ LOOP:&lt;BR /&gt;$ READ/END_OF_FILE=ENDIT IN NAME&lt;BR /&gt;$ HOST = F$EXTRACT(F$LOCATE("4 packets",NAME),100 ,NAME)&lt;BR /&gt;$ HOST=f$edit(HOST,"TRIM,COMPRESS")&lt;BR /&gt;$ rest=f$edit(f$element(2,",",HOST),"TRIM")&lt;BR /&gt;$ perc=f$element(0," ",rest)&lt;BR /&gt;$ IF HOST .EQS. ""&lt;BR /&gt;$ THEN&lt;BR /&gt;$    GOTO LOOP&lt;BR /&gt;$ ELSE&lt;BR /&gt;$    SHOW SYMBOL PERC &lt;BR /&gt;$ ENDIF&lt;BR /&gt;$ ENDIT:&lt;BR /&gt;$ CLOSE IN&lt;BR /&gt;&lt;BR /&gt;Now, with this value can use it to know wicht devices are working, etc and a new syntaix for future&lt;BR /&gt;&lt;BR /&gt;Thanks againt for your help</description>
      <pubDate>Wed, 17 Nov 2010 16:07:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263141#M40783</guid>
      <dc:creator>Marcos Llano</dc:creator>
      <dc:date>2010-11-17T16:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263142#M40784</link>
      <description>Done</description>
      <pubDate>Wed, 17 Nov 2010 16:08:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263142#M40784</guid>
      <dc:creator>Marcos Llano</dc:creator>
      <dc:date>2010-11-17T16:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263143#M40785</link>
      <description>Marcos,&lt;BR /&gt;&lt;BR /&gt;You may want to take a step back and look at the larger problem you are trying to solve.&lt;BR /&gt;What are you going to do next with that PERC symbol value?&lt;BR /&gt;&lt;BR /&gt;I can parse text files with DCL with the best of them, and even enjoy doing that (yeah, twisted person), but sometimes there are better tools.&lt;BR /&gt;&lt;BR /&gt;For just playing around with strings I find PERL and AWK very convenient.&lt;BR /&gt;&lt;BR /&gt;Here, for example to just get that specific string:&lt;BR /&gt;&lt;BR /&gt;perl -ne "print $1 if /(\d+)% packet loss/" tmp.tmp&lt;BR /&gt;&lt;BR /&gt;Want to add the host name to that?&lt;BR /&gt;&lt;BR /&gt;perl -ne "$host=$1 if /^----(\S+)\s+PING/; print qq($host $1) if /(\d+)% packet loss/" tmp.tmp&lt;BR /&gt;&lt;BR /&gt;Enjoy!&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Nov 2010 16:56:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263143#M40785</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-17T16:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263144#M40786</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The objetive of this job is know which terminal are in use after working hour. So I need a value to know if the terminal is switched-on. My first idea was make a ping. If don't response, then the Thinclient are swiched-off. &lt;BR /&gt;Of course, I can use a Nagios system to monitor if a terminals are swhitched-on or not. But I think that this way is more interesting to learn and gain experience (I'm new in this environment)&lt;BR /&gt;&lt;BR /&gt;Thanks and regards</description>
      <pubDate>Thu, 18 Nov 2010 08:35:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263144#M40786</guid>
      <dc:creator>Marcos Llano</dc:creator>
      <dc:date>2010-11-18T08:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263145#M40787</link>
      <description>If you are new to this, and want to make it more interesting then I urge you to pick up Perl and for this specific exercise check out its 'ping' extension. This will allow you to build a nicely integrated solution which can run unaltered on OpenVMS, Linux or Windoze as you see fit.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.</description>
      <pubDate>Thu, 18 Nov 2010 14:03:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263145#M40787</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-18T14:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a specific string</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263146#M40788</link>
      <description>perl has a ping module available, and python and other scripting languages make this task trivial.   &lt;BR /&gt;&lt;BR /&gt;I'd even use C here (with any of the available ping libraries) long before I'd try using DCL, too.  DCL is an increasingly poor choice.&lt;BR /&gt;&lt;BR /&gt;That written, it would not surprise me to learn that this problem has already been solved.   Dozens of times.  Why even write code if you don't need to?</description>
      <pubDate>Thu, 18 Nov 2010 14:16:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/extracting-a-specific-string/m-p/5263146#M40788</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2010-11-18T14:16:47Z</dc:date>
    </item>
  </channel>
</rss>

