Copying the Header & footer Information to the Outfile.
Hi
I am writing a perl script which checks for the specific column values from a file and writes to the OUT file.
So the feed file has a header information and footer information.
I header information isaround107 lines i.e.
Starts with
After the last line "# PRODUCT=Corp/Pfd" the actual data would start.
The footer information is 4 lines i.e.
Now, My perl script is as below:
1)Here Before going to check the column values, I need to write the HEADER and FOOTER information to the Goodfile
2) Also, I need to calculate the Number of Records in the Good file and then change the FOOTER Information as:
Could anyone please help me out in solving this. Help would be really appreciated.
I would like to remove some lines from begining of file (header) and some lines from end of file (footer).
The header/footer lines generated by web-browser when the user upload a file to my webserver.
Example:
-----------------------------7d62af20c052c
Content-Disposition: form-data;... (2 Replies)
Hi Gurus,
My requirement is, I am passing a file1.dat into this(rowcnt.sh) script,but returning a wrong value of -2.(it should be 4).Becoz my file1.dat contains 6records incl: Header & Footer.(6-2=4)
wrong output:
-------
#sh rowcnt.sh file1.dat
-2 actual_cnt except HDR & FTR
should be:... (3 Replies)
Hi All,
I have several txt files i need to enter specific header and footer (both are separate) to all these files how can i do this? plz help..
Regards,
Raghav (4 Replies)
Hi, Guys,
I want add header and footer in a file. I can add footer using following command:
echo "Footer" >>file.
I don't know how to add header.
Thanks in advance (4 Replies)
Hi,
I need to check whether the incoming file has a header and footer using a UNIX script. The pattern of the header and footer is fixed as follows:
Header: Name,Date
Footer: Count, Total
Name,Date
-------------------------
-------------------------
-------------------------
Count,... (5 Replies)
Hi,
TASK 1:
I have been using this code to print the information of files kept at "/castor/cern.ch/user/s/sudha/forPooja" in some text file name FILE.txt.
rfdir /castor/cern.ch/user/s/sudha/forPooja | grep data | awk '{print "rfio:///castor/cern.ch/user/s/sudha/forPooja/"$9}' > FILE.txt
... (6 Replies)
Hi All,
I need to write a script that In my file I have to check header and footer records are available or not. If it is available I have to run the script, otherwise I should not. But current script it is checking only the data inside the script. It is avoiding to check Header and Footer... (1 Reply)
I have two files which are getting sent to a UNIX server in order to be bcp'd into a database. The bcp is failing because there's a header and footer row on the file which give the date of the file and the number of rows in it. That's because the file is also being used for another process, so we... (1 Reply)
This is my file(Target.txt)
name|age|locaction
abc|23|del
xyz|24|mum
jkl|25|kol
The file should be like this
1|03252012
1|name|age|location
2|abc|23|del
2|xyz|24|mum
2|jkl|25|kol
2|kkk|26|hyd
3|4
Column 1 is row indicator
for row 1 and 2, column indicator is 1,for data rows... (1 Reply)
Hi I have below requirements on the script below :
(1) I receive 2 pipe seperated file called OUT.psv and DIFF.psv with a column header.I concatenate the 2 files and create a final.psv file. I want to add another header as START_FILE to the final.psv file . How to achieve this ?
(2) I have... (5 Replies)
Discussion started by: samrat dutta
5 Replies
LEARN ABOUT DEBIAN
net::sip::packet
Net::SIP::Packet(3pm) User Contributed Perl Documentation Net::SIP::Packet(3pm)NAME
Net::SIP::Packet - handling of SIP packets
SYNOPSIS
use Net::SIP::Packet;
my $pkt = eval { Net::SIP::Packet->new( $sip_string ) }
or die "invalid SIP packet";
$pkt->get_header( 'call-id' ) || die "no call-id";
$pkt->set_header( via => @via );
print $pkt->as_string;
DESCRIPTION
This module implements the parsing, manipulation and creation of SIP packets according to RFC3261.
NET::SIP::Packet's objects can be created by parsing a string containing the SIP packet or by constructing it from parts, e.g. header keys
and values, body, method+URI (requests) or code+text (responses).
All parts can be manipulated and finally the string representation of the manipulated packet can be (re)created.
For dealing with requests and responses directly usually the subclasses Net::SIP::Request or Net::SIP::Response will be used instead.
EXAMPLES
# create packet from string
my $invite = Net::SIP::Packet->new( <<'EOS' );
INVITE sip:you@example.com SIP/2.0
From: <sip:me@example.com>
To: <sip:you@example.com>
...
EOS
# show and manipulate some header
print "callid=".$invite->get_header( 'call-id' )."
";
print "route=".join( ",", $invite->get_header( 'route' ))."
";
$invite->set_header( 'via' => [ $via1,$via2,.. ] );
# get resulting string representation
print $invite->as_string;
# create packet from parts
my $resp = Net::SIP::Packet->new(
200, 'Ok',
{ to => '<sip:you@example.com>', from => '<sip:me@example.com>',.. }
Net::SIP::SDP->new(...)
);
# and get the packet as string
print $resp->as_string;
CONSTRUCTOR
new ( STRING | @PARTS )
This is the default constructor. Depending on the number of arguments branches into new_from_string or new_from_parts.
new_from_string ( STRING )
Interprets STRING as a SIP request or response and creates Net::SIP::Request or Net::SIP::Response object accordingly. Will die() if
it cannot parse the string as a SIP packet.
new_from_parts ( CODE|METHOD, TEXT|URI, \%HEADER|@HEADER, [ BODY ] )
If CODE|METHOD is numeric a Net::SIP::Response object will be created with the response code CODE and the text TEXT. Otherwise a
Net::SIP::Request object will be created with the method METHOD and the uri URI.
Header data can be given as a hash %HEADER or array @HEADER reference. In case of a hash the key is the SIP field name and the value
as either a string or a @list of strings. The fields on the resulting SIP packet will be sorted by name of the fields and fields with
multiple values will be created as seperat lines.
If the header is given as an array the elements of the array are "[ key => value ]" pairs where the keys are the field names and the
values are strings or @list of strings. Each pair will result in a single line in the SIP header. If the value was a list reference
the values in the list will be concatened by ','. The order of the fields in the resulting SIP packet will be the same as in the
array.
The BODY is optional and can be given either as a string or as an reference to an object which has a method as_string, like
Net::SIP::SDP. If the BODY is an object which has a method content_type it will set the "content-type" header of the SIP object based
on the result of "BODY->content_type" unless a "content-type" header was explicitly given.
METHODS
is_request
Returns TRUE if the SIP packet is a request, otherwise FALSE.
is_response
Returns TRUE if the SIP packet is a response, otherwise FALSE.
tid Returns a transaction ID created from the sequence number in the "CSeq" header and the "Call-Id" header. All packets with the same tid
belong to the same transaction.
cseq
Returns "CSeq" header. Short for "$self->get_header( 'cseq' )".
callid
Returns "Call-Id" header. Short for "$self->get_header( 'call-id' )".
get_header ( [ NAME ] )
If NAME is given it returns the SIP header for NAME. If no header exists returns (). If there is only one value for the header returns
this value. In case of multiple values it returns a @list of all values, but if "wantarray" says, that the caller expects only a single
value it will "croak()".
If no NAME is given it will return a reference to a hash wich contains all fields and has the format described in new_from_parts.
add_header ( NAME, VAL )
Adds the header at the end of the SIP header. VAL can be a string or a reference to a list of strings.
insert_header ( NAME, VAL )
Like add_header, but the lines will be added on top of the header.
del_header ( NAME )
Delete all lines from header where the field name is NAME.
set_header ( NAME, VAL )
Replaces an existing header, like del_header followed by add_header.
set_body ( VAL )
Sets body to VAL, which can be string or object. The handling for body objects see new_from_parts.
as_string
Returns string representation of SIP packet.
dump ( [ LEVEL ] )
Returns dump of packet as string for debugging. The higher LEVEL is the more details one gets. At the moment a LEVEL of 0 gets a one-
line summary and the rest the result from as_string.
as_parts
Returns Array with CODE|METHOD, TEXT|URI, @HEADER and BODY like used in new_from_parts.
sdp_body
Returns body as Net::SIP::SDP object if there is a body and the content-type is 'application/sdp' or empty.
If body contains invalid SDP it raises an exception (e.g. die()).
UNDOCUMENTED METHODS
get_header_hashval ( [ NAME ] )
scan_header ( @ARG )
clone
perl v5.14.2 2011-08-26 Net::SIP::Packet(3pm)