CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
this is a tough one...my script is so close of working please help

 



sclark
New User

Aug 14, 2002, 7:03 AM

Post #1 of 2 (1259 views)
     this is a tough one...my script is so close of working please help  

ok here is part of my script:

sub hextodec {
unpack("N", pack("H32", substr("0" x 32 . shift, -32)));
}
sub dectohex {
unpack("H", pack("N32", substr("0" x 32 . shift, -32)));
}

$rawpacket=~s/< +42//s;
$rawpacket=~s/< +90.*//s;
$rawpacket=~s/> +(48 .*)//;
$cmd90header=$1;
($null, $null, $null, $null, $cmd90len) = split(' ', $cmd90header, 5);
$outstr = hextodec($cmd90len);
$rawpacket=~s/> +//gs;
$rawpacket=~s/\n\n//gs;
$cmd90body=$rawpacket;
$cmd90file="cmd90.xpl";
open(CMD90,">>$cmd90file");
print CMD90 $cmd90header."\nr01".$rawpacket."r".$outstr."\n"."r02\n\n";
close CMD90;


now it read a file that looks like this:

48 42 00 00 (48) <--------here

90 46 40 03 75 d5 2b b4 48 a5 b0 33 10 af dd 87
18 63 a8 fa 1e 82 f3 5e 21 1e 76 7e 3f 6c 46 f4
85 4a 6c a4 4d fb 05 fc 46 df e6 1f a7 76 80 3d
8d d1 52 80 f1 da 43 67 ab 8d e6 43 72 86 d6
08 8e 70 0a ef 44 51 d1 c4

now the 48 42 00 00 (48) the last 48 this can be a hex or a dex number i need it to take this number subtract 0E in hex from it convert it to dec then sub 14 then convert the answer back to hex.

then print it to the cmd90.xpl file so it looks like this:

48 42 00 00 48
r01
90 46 40 03 75 d5 2b b4 48 a5 b0 33 10 af dd 87
18 63 a8 fa 1e 82 f3 5e 21 1e 76 7e 3f 6c 46 f4
85 4a 6c a4 4d fb 05 fc 46 df e6 1f a7 76 80 3d
8d d1 52 80 f1 da 43 67 ab 8d e6 43 72 86 d6
08 8e 70 0a ef 44 51 d1 c4
r3a <-------here
ro2

notice the r3a is the right math way BUT mine don't work my prints it out like this:

48 42 00 00 48
r01
90 46 40 03 75 d5 2b b4 48 a5 b0 33 10 af dd 87
18 63 a8 fa 1e 82 f3 5e 21 1e 76 7e 3f 6c 46 f4
85 4a 6c a4 4d fb 05 fc 46 df e6 1f a7 76 80 3d
8d d1 52 80 f1 da 43 67 ab 8d e6 43 72 86 d6
08 8e 70 0a ef 44 51 d1 c4
r0 <-------here
ro2

see the r0? i can't get the math to work right? any ideas please


thanks


fashimpaur
User / Moderator

Aug 14, 2002, 9:25 AM

Post #2 of 2 (1257 views)
     Re: [sclark] this is a tough one...my script is so close of working please help [In reply to]  

Please stop posting in multiple forums. This thread has been locked. See similar post in intermediate forum.
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives