|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I created a small little script (for monitoring traffic on my site):
#!/usr/bin/perl use Socket; print "\nWebsite Monitor v0.01a\n~~~~~~~~~~~~~~~~~~~~~~\n\n"; my $proto = getprotobyname('tcp'); socket(SH, PF_INET, SOCK_STREAM, $proto) || die $!; my $sin = sockaddr_in(31337, INADDR_ANY); bind (SH, $sin) || die $!; listen (SH, 150); $kill = 0; while($kill != 1) { accept (FH, SH) || die $!; $store = <FH>; chomp $store; print $store . "\n"; if($store == "KILL") { $kill = 1; } close(FH); } It'll do until I want to add to it (filter out someone just telnetting to it, e.t.c ) The problem I am having here is getting it to kill itself, by setting $kill to 1. If I use the "==" operators it will always kill itself no matter what $store is. If I use the "eq" operator KILL will never match $store... I tried messing around with chomp (look at above code), e.t.c but I just don't understand what wrongs. Can anyone help?Thanks in advance! |
|
#2
|
|||
|
|||
|
I was also thinking another way I could do this was to just type in KILL in the console the scrip is running in, and it would kill itself. Instead of having to telnet to it and tell it to KILL itself.
Sorry if this seems like such a simple problem, but I'm just a begginer so please bear with me. |
|
#3
|
||||
|
||||
|
"eq" is a string comparison operator, "==" is a numerical comparison operator.
Remember, perl will do type conversion for you if you ask it do, even if it doesn't make a lot of sense. Like in. . . Code:
if($store == "KILL")
{
$kill = 1;
}
What's the numerical value of the word "KILL"? That's what perl is trying to compare $store to. I don't know what this would get you, but I do know you're using the wrong operator. This doesn't really look like a website monitor. . .What's it for, really? You're binding to the BackOrifice port. . . Not that I care. . . |
|
#4
|
|||
|
|||
|
lol, I never realized I was binding to the BO port until you just mentioned it. I just used it because it's the first thing that came to mind... eleet. I normally hate people who use 31337 format but I couldn't think of anything.
Anyways if $store stores "KILL" then '$store eq "KILL"' should return true right? If it is comparing ASCI they both should equal the same thing... The way I making this a website monitor is by having this running on my screen, while on my website I'll just add a small piece of code to write "IP - /index.php - TIME" or something similar to that format. It's really just a small little project just for the heck of it. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > == or eq? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|