Home  |  Linux  | Mysql  | PHP  | XML
From:Curt Shaffer Date:Mon Feb  8 18:55:05 2010
Subject:Re: sequential value check
OK. So I have tried some things. I guess the largest issue that I can't find an answer for elsewhere is how to evaluate variables to be >, = or <100 in one evaluation.

Before I get there, obviously I need to get the variables.

Here is what I am trying to do for that:

@hping_array = ();
$hcount = 1;
for (; $hcount < 5;){

        system ("sudo hping3 $domain -S -p 80 -c 1|awk '{print $5}'");
        chomp;
        push hping_array, $_;
        $hcount++;
}
print "@hping_array\n";

So the code is trying to run the hping3 command against $domain. I am awking for $5 which is the IPID value in the response. I am trying to push it into the array @hping_array. This should happen 5 times.

Then I'm printing @hping_array. I'm only getting one value and it is actually the whole response from hping. It seems to not respect the awk. 

#example output

HPING www.example.com (en1 xxx.xxx.xxx.xxx): S set, 40 headers + 0 data bytes
len=46 ip=xxx.xxx.xxx.xxx ttl=64 DF id=2041 sport=80 flags=SA seq=0 win=5840 rtt=1.4 ms

I have done this partially with just doing my $hping_result = `sudo hping3 $domain -S -p 80 -c 1|awk '{print $5}'; So I know the system command by itself is working.

So first question is what can help me get just the $5 into array 5 times. Then I can move on to evaluation of the array values.



On Feb 8, 2010, at 6:03 PM, Uri Guttman wrote:

>>>>>> "CS" == Curt Shaffer <cshaffer@gmail.com> writes:
> 
>  CS> I'm trying to figure out a way to compare a couple values to see
>  CS> if they are sequential or not.  I'm running a for loop and
>  CS> grabbing a value and setting a variable through each iteration. At
>  CS> the end I would like to examine the results and see if they are
>  CS> sequential or not.
> 
>  CS> If the values are less or more than 100 of the last then print
>  CS> something like "not sequential". If they are equal or less than
>  CS> 100 greater then the last then print "possibly sequential".
> 
> this sounds like an easy problem. why don't you try to code it up and
> then post that code here. then we can help you with your solution.
> 
>  CS> Can anyone point me at a way to do this?
> 
> it is best to work it out for yourself and then ask for help. this is a
> simple problem that shouldn't need guidance for a solution. just write
> code that reflects what you said in english. if you have trouble, write
> more specific english with concrete details. that is easier to translate
> to code.
> 
> thanx,
> 
> uri
> 
> -- 
> Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
> -----  Perl Code Review , Architecture, Development, Training, Support ------
> ---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: [PHP-INSTALL] Browser tries to download php file
Re: [PHP] php selecting multiple stylesheets
RE: Global scope
Trying to decide between MDB2 and PHP PDO
Re: Web photo album, is this possible in CGI


  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants