[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-date: Fri May 6 20:02:47 2005 -->
- <!--x-from-r13: psbjyre ng bhgcbfgfragvary.pbz (Quevfgbcure Tbjyre) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Extracting a second line -->
- <li><em>date</em>: Fri May 6 20:02:47 2005</li>
- <li><em>from</em>: cfowler at outpostsentinel.com (Christopher Fowler)</li>
- <li><em>subject</em>: [ale] Extracting a second line</li>
> Code: 400 Time: 23:51:04 UTC 05-MAY-2005 SN: 00824 Version: 1.42
Promedica Bixby Medical Center - 818 Riverside Avenue Adrian Mi
I use Expect on the file handle to check for that data.
$location_regex = "Code: 400
([[:print:]])*([[:cntrl:]])+([[:print:]])*([[:cntrl:]])+";
push @triggers, cook_regex(undef, $location_regex, "LOCATION");
Here is execution of expect:
my (undef, $error) = $exp->expect(0, @triggers);
So if Expect sees two lines of data that starts with 'Code: 400' Then
self->match will have the text that caused the match.
Output:
[cfowler at ze1250 gk]$ sudo ./gk.pl -p /dev/ttyS1 -o DEMO -v -D 3 -f SH
05-06 12:02:27 Initilizing Modem.
05-06 12:02:27 Modem initialized.
05-06 12:02:33 Incoming call. Answering..
05-06 12:02:44 Call answered.
05-06 12:02:47 Found: Code: 400 Time: 23:51:04 UTC 05-MAY-2005 SN: 00824
Version: 1.42
05-06 12:02:47 Promedica Bixby Medical Center - 818 Riverside Avenue
Adrian Mi
05-06 12:02:47 Location information received.
05-06 12:02:55 Call Terminated.
05-06 12:02:56 Initilizing Modem.
05-06 12:02:56 Modem initialized.
I need to somehow extract the location information from the second line.
I know that it has leading spaces. I want all the text after the
leading spaces. I do not know if the first lines ends in '\n','\m' or
'\r\n' so that is why in the POSIX regex I used ([[:cntrl:]])+ to detect
the end of the first and second lines so I can get them both.
Can someone tell me that if I have a string that looks like this
"Code: 400 Time: 23:51:04 UTC 05-MAY-2005 SN: 00824 Version: 1.42
Promedica Bixby Medical Center - 818 Riverside Avenue Adrian Mi"
and based on the knows above how I can extract all the data past the
leading spaces on the second line? Also is there a better regex I can
use for Expect?
Thanks,
Chris
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00091.html">[ale] U.S. National Identity Cards All But Law</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00093.html">[ale] U.S. National Identity Cards All But Law</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00081.html">[ale] Extracting a second line</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00083.html">[ale] Anyone installed Linux on Fry's "Great Quality" laptops?</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00092"><strong>Date</strong></a></li>
<li><a href="threads.html#00092"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>