Hi,
I'm using script to grab following comma separated data from telnet port. (x86, Windows, ActivePerl) There is coming quite a lot of data from port. several lines per second producing hudreds kilobytes logfile in small time.
Link to example rawdata which is coming out from telnet port:
http://oh2gax.dyndns.o rg/~ode/kamaa/logfile_raw.txt
The script grabs only that lines which started with MSG,3 split the data and takes needed columns from it. Then it reproduces date stamped file with following format:
3C5122,60.34987 ,25.01473,1050, 14:50:36.275
461F35,60.45609 ,25.17939,3575, 14:50:36.275
3C6663,59.48836 ,21.67773,33025 ,14:50:36.275
The functionality what I want:
I need to grab the additional data from message line MSG,4. Normally these lines are pairs, MSG,4 line after the MSG,3, but sometimes there are only MSG,3 followed by MSG,8 or any other. I want grab now also additional columns from MSG,4 line which immediately after MSG,3 and only then when data on fifth column (look raw_data) (etc. 462F95) is same in both lines.
MSG,3,7,5439,46 2F95,......
MSG,4,7,5439,46 2F95,......
Producing data line for example:
462F95,60.45609 ,25.17939,3575, 428.2,217.2,14: 50:36.275
If, column 5 in MSG,4 line doesn't match with MSG,3 or line is totally different, only MSG,3 line is taken and additional column data is replaced in that case with values 0.0,0.0.
etc.
462F95,60.45609 ,25.17939,3575, 0.0,0.0,14:50:3 6.275
I'am very new with Perl, and would be very glad if someone could give help to create code with above functionality. Do I have to do some data buffering or make temporaly files?
---- -
#!/perl
-
use Net::Telnet;
-
my $host = "hostname";
-
my $user = "";
-
my $password = "";
-
my $prompt = "";
-
my (@data, $line);
-
my $t = new Net::Telnet(Timeout=> '5', port => '23');
-
$t->errmode('return');
-
$t->Net::Telnet::open($host);
-
sleep 5;
-
while (<$t>)
-
{
-
if (m/MSG,3/)
-
{
-
#print;
-
@data = split(/,/);
-
-
($day, $month, $year) = (localtime)[3, 4, 5];
-
$year += 1900;
-
$month++;
-
$date = sprintf '%02u%02u%02u', $day, $month, $year;
-
#print $date;
-
-
open LOGFILE, ">>$date.txt" or die "Can't open file";
-
print LOGFILE $data[4].",".$data[14].",".$data[15].",".$data[11].",".$data[7]."\n";
-
print $data[4]." ".$data[14]." ".$data[15]." ".$data[11]." ".$data[7]."\n";
-
}
-
}
-
$t->close();
-
-
laxlou
1 2847
Problem solved, no help needed anymore. :-)
---
laxlou
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Craig Keightley |
last post by:
is it possible to compare acomma separated list aginst another
eg comma list 1 => 1,2,3,4,5
comma list 2 => 3,5
can you check that 3 is in both, and 5 is in both, therfore they match???
the comparison is to check that if product a who supplies products 1,2,3,4,5
can be used instead of product b who supplies 3,5 as product a already
supplies them
|
by: john brown |
last post by:
I'm telnetting into a router. Apart from the fact I can't seem to
view the output when iniciating the session, I can't match one of the
expressions using Net::Telnet. I can telnet into the router manually
without a problem. I'm running a sniffer at the same time just to see
what's happening behind the scenes. The computer does an ARP request
looking for the router's direction, but that seems to be it. I don't
think any data actually...
|
by: Michael Hill |
last post by:
Hi, folks.
I am writing a Javascript program that accepts (x, y) data pairs from
a text box and then analyzes that data in various ways. This is my
first time using text area boxes; in the past, I have used individual
entry fields for each variable. I would now like to use text area
boxes to simplify the data entry (this way, data can be produced by
another program--FORTRAN, "C", etc.--but analyzed online, so long as
it is first...
|
by: pesso |
last post by:
I have a string that contains the following:
string s = "130,41,43,178,41,17,6,78,244,35,202,144,115";
They are comma separated byte numbers, and I need to
initialize my byte array with them. Looks like I need a loop
or something. What would be the best way to take a
comma separated string to initialize a byte array using cs?
|
by: bneron |
last post by:
hello,
I use the logging module include in Python 2.4 distribution, and I 'd
like to have a logger witth several Handlers .
I know how to do this by coding in python, but could I specify this
directly in the logger configuration file?
Thanks in advance!
bertrand
| |
by: mac |
last post by:
Hi,
I'm trying to write a fibonacci recursive function that will return
the fibonacci string separated by comma. The problem sounds like this:
-------------
Write a recursive function that creates a character string containing
the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) =
F(1) = 1 -, separated by comma. n should be given as an argument to
the program. The recursive function should only take one parameter, n,
and...
|
by: mac |
last post by:
Hi,
I'm trying to write a fibonacci recursive function that will return
the fibonacci string separated by comma. The problem sounds like this:
-------------
Write a recursive function that creates a character string containing
the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) =
F(1) = 1 -, separated by comma. n should be given as an argument to
the program. The recursive function should only take one parameter, n,
and...
|
by: sufian |
last post by:
Below is the field where user enters his/her email address and the AJAX post request is sent to the server and the user sees the message:
echo("<div id=\"message\" class=\"success\">Thank you! You have been successfully registered.</div>");
within 1.5 seconds.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta...
|
by: ravimath |
last post by:
Dear all,
I have written following script to loin to router bu it is showing error.
#!c:\Perl\bin;
use strict;
use warnings;
my $hostname = 'REMOVED FOR YOUR PROTECTION';
my $password = 'REMOVED FOR YOUR PROTECTION';
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |