Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 2nd, 2001, 08:14 PM
shockwire shockwire is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Bellingham, WA
Posts: 0 shockwire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to shockwire Send a message via AIM to shockwire
Question == or eq?

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!

Reply With Quote
  #2  
Old August 2nd, 2001, 08:21 PM
shockwire shockwire is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Bellingham, WA
Posts: 0 shockwire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to shockwire Send a message via AIM to shockwire
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.

Reply With Quote
  #3  
Old August 3rd, 2001, 08:48 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
"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. . .

Reply With Quote
  #4  
Old August 3rd, 2001, 07:51 PM
shockwire shockwire is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Bellingham, WA
Posts: 0 shockwire User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to shockwire Send a message via AIM to shockwire
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > == or eq?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway