Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Sunday, October 5, 2008

Notes for tcpdump

Note 1 
I run tcpdump in iphone to listen to the packet traffic
I run "tcpdump -vvv -i en0 > en0" and "tcpdump -vvv -i pdp_ip0" at the same time in the terminal.
I the result file "en0", I find the following
"
>>> NBT UDP PACKET(138) Res=0x110E ID=0x81CE IP=169 (0xa9).254 (0xfe).223 (0xdf).49 (0x31) Port=138 (0x8a) Length=197 (0xc5) Res2=0x0 
SourceName= 
WARNING: Short packet. Try increasing the snap length
"
I searched it and this needs not to be worried.

It's not something to be worried about. It's not a FreeBSD or 
SAMBA problem, either. 

It's tcpdump complaining about snaplen (-s ) being 
shorter than at least one packet it encountered in the stream.

For recovery purpose, I rewrite this line to "(Recovered by Junxian )id 33230, offset 0", so that the id can be recorded by my Perl script.

Start to learn Perl: Difference between single-quote and double-quotes

$s = 1;
print '$sAND\n';  will result in
$sAND\n
While
print "$s \n"; will result in
1AND

In single-quote, compiler leaves everything what they are, while for double-quotes, special characters will be replaced

Refer to this page.

Start to learn Perl: Differences among exists, defined, and true

my %h = ();
#%h is a hash table
$h{'undef'} = undef;
$h{'defined_but_false'} = 0;
$h{'defined_and_true'} = 'true';

$key = 'undef';
print "Value EXISTS, but may be undefined.\n" if exists  $h{ $key };
print "Value is DEFINED, but may be false.\n" if defined $h{ $key };
print "Value is TRUE at h key $key.\n"     if         $h{ $key };
print "\n";

$key = 'defined_but_false';
print "Value EXISTS, but may be undefined.\n" if exists  $h{ $key };
print "Value is DEFINED, but may be false.\n" if defined $h{ $key };
print "Value is TRUE at h key $key.\n"     if         $h{ $key };
print "\n";

$key = 'defined_and_true';
print "Value EXISTS, but may be undefined.\n" if exists  $h{ $key };
print "Value is DEFINED, but may be false.\n" if defined $h{ $key };
print "Value is TRUE at h key $key.\n"     if         $h{ $key };
print "\n";

____________________________________________________________
Store the above to "test.pl"
and run "perl test.pl"
You will get the following results:

"
Value EXISTS, but may be undefined.

Value EXISTS, but may be undefined.
Value is DEFINED, but may be false.

Value EXISTS, but may be undefined.
Value is DEFINED, but may be false.
Value is TRUE at h key defined_and_true.
"

So if a variable is true, then it is defined, and if a variable is defined, then it exists.
But reverse is not true.
A variable exists but may not have been defined, and a variable is defined but may not be true

Friday, October 3, 2008

How to install perl in Windows XP

Download ActivePerl from here or here.
You need to input your name and email.
But it is free

Begin installation, follow the steps

[Check] Add Perl to the PATH environment variable
[Check] Create Perl file extension association
And your installation will be smooth.

refer to this page

After installation finished,  you will see the release note
"

ActivePerl 1004 -- Release Notes

Welcome, and thank you for downloading ActivePerl. This release corresponds to Perl version 5.10.

The following platforms are supported by this release:

  • AIX 5.1 or later (rs6000)

  • Linux: glibc 2.3 or later (x86 and x64)

  • Mac OS X 10.4 or later (x86 and powerpc)

  • Solaris 2.8 or later (sparc, 32 and 64 bit)

  • Solaris 10 or later (x86)

  • Windows 2000 (x86)

  • Windows XP, 2003, Vista (x86 and x64)

    blablabla

"
It is very cool to support so many platforms.


Apache conf
You have to have your apache web server running.
In "C:\Program Files\Apache Software Foundation\Apache2.2\conf"
Edit the httpd.conf file which is the configuration file of apache server in the following way

Activating CGI
Using Notepad (or other text editor) openhttpd.conf (also should be start-menu shortcut called "Edit Apache HTTP httpd.conf File") and search for Options Indexes "FollowSymLinks" (about line 217) when you find it add "ExecCGI" to the end so it looks like "Options Indexes FollowSymLinks ExecCGI"

You should restart your apache server after these changes
this page is very helpful for you to get perl cgi runing properly