Good Day,
This program is part of my full program.
This part should be working independently.
What it does is:
Get file from one directory "inboundd".
Read the file.
Construct MO (MO is a string will be passed via tcp/ip).
Might be some one looking for this kind of, or part of the code here.
#!/usr/bin/perl --
sub hex_to_ascii ($)
{
# Convert each two-digit hex number back to an ASCII character.
(my $str = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
return $str;
}
chdir( "inboundd/" );
local( @files ) = <*.dat>;
if($files[0] ne ""){
$GetFile = $files[0];
@FileHeader = split("_",$GetFile);
if($FileHeader[0] eq "DN"){
system "cp $GetFile ../DN_Dump/";
unlink($GetFile);
}
else{
open (CHECKBOOK, "$GetFile") || die "couldn't open the fil
+e!";
while ($record = <CHECKBOOK>) {
$InString .= $record;
}
close(CHECKBOOK);
system "cp $GetFile ../MO_Dump/";
unlink($GetFile);
}
}
chdir("../");
# GETTING THE FILE OUT AND FORM MO
#print "The MO Received $InString \n";
if($InString ne ""){
@InArrData = split(",",$InString);
$InMobile = $InArrData[1];
$InShortcode = $InArrData[6];
$InVendor = $InArrData[7];
$InMsgHex = $InArrData[5];
$InKeyword = $InArrData[10];
$InInbound = $InArrData[9];
$InMsg = &hex_to_ascii($InMsgHex);
$InAnswer = "mo:$InMobile:$InShortcode:$InInbound:$InVendor:$I
+nMsg\n";
}
print $InAnswer;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.