mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2005
Posts: 3
P
PillBox Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Dec 2005
Posts: 3
Hi

I'm New at scripts and I wanted what I think is a simple task to be performed but got "complicated" answers from searching the Forum.

-ping a host (in the form of IP address)
-get info "up" or "down" and return it in mirc window

Sorry if this has been discussed but I can't understand any of the related topics I found, if someone could post the code and explain me how it works (kind of step by step) I'd appreciate it.

Cheers!

Last edited by PillBox; 21/12/05 03:39 AM.
Joined: Jun 2005
Posts: 127
H
Vogon poet
Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
http://www.mirc.net/projects.php?view_snippet=1083936635

Usage: $_ping(domain.tld)

Edit: After re-reading your post i saw that you mentioned that you were new, so ill explain further. $_ping(domain.tld) when used in a msg command will be replaced by the ping time. It uses the DOS command PING, and will return a value like time=123ms. So, if you wanted something like this...

<User> !ping google.com
<Bot> Google.com Reponded in 123ms

...Then you could use something like this:
Code:
on *:text:!ping*:#: { msg $chan $2 $iif($_ping($2) == $false,Did Not Respond,Responded in $remove($v1,time=)) }


If you just wanted a simple alias to use for yourself, something like this should work:
Code:
alias sping { echo -a $1 $iif($_ping($1) == $false,Did Not Respond,Responded in $remove($v1,time=)) }


Of couse, for either of these to work you need to download and add the script I linked above to your remotes.

Good luck.

Last edited by HAMM3R; 21/12/05 07:29 AM.
Joined: Dec 2005
Posts: 3
P
PillBox Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Dec 2005
Posts: 3
Thank you very much HAMM3R, it works perfect! and thank you for spending the time to explain it.

By the way, is it possible to scan a specific port from that host and return if it's opened or closed? I'ts just icing on the cake, not mandatory, but would be neat =) (searched again the forum but returned no usefull info)

Cheers!

Last edited by PillBox; 21/12/05 01:00 PM.
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
If all you want to do is check if a host is up, then you don't need to send a ping, you can simply open a socket to the address, and close it immediately in the sockopen event, checking for $sockerr.

For the relevant code (it's 4 lines) check here

Needless to say, this is a much more efficient solution than what you've been given.


Gone.
Joined: Dec 2005
Posts: 3
P
PillBox Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Dec 2005
Posts: 3
FiberOPtics on a personal note: I'm new to scripting and you can check it from my reg date on this boards and the ridiculously simple tasks I'm unable to perfrorm on mIRC, that's why I seek help. If it bothers you to answer my questions (because they are not a challenge for you I presume) then don't answer, I'm sure others might be more whilling to do so.

Your option returns the same result as the option provided by HAMM3R, actually it gives less info (no delay status) as well as the handling of the info is somewhat harder to manipulate (although I might find a way to change the output).

And I didn't input any port on the alias so it still doesn't solve that question. The host has many different ports opened and I want to have one specifically checked.

By the way, in the mean time, I found the host has an xml file with the info I need, wich is easier to handle (since I've read numerous problems and solutions on the boards) and I'll try this approach to the problem meanwhile. Even so I'd still like to know how to perform the port check on mIRC (if it's possible) since I'd rather have the info directly from the source.

Cheers!

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
FiberOPtics on a personal note: I'm new to scripting and you can check it from my reg date on this boards and the ridiculously simple tasks I'm unable to perfrorm on mIRC, that's why I seek help. If it bothers you to answer my questions (because they are not a challenge for you I presume) then don't answer, I'm sure others might be more whilling to do so.


Where did that come from all of the sudden?

I simply gave you a far less intensive means to do the same as what hammer gave you, since his runs an exe which writes the results to a file, and this file needs to be read from, which is a lot less efficient than what I gave you. The output can be changed to any way you want, just change the code around.

I didn't even see you mentioned anything about port scanning, and if you're going to have such an attitude towards me, then don't think I'll bother helping you further.


Gone.
Joined: Jun 2005
Posts: 127
H
Vogon poet
Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
I agree. His way is more efficient. However, (i may be wrong) it seems that code would only work to verify wheather a host has a public webserver running on port 80. Maybe other hosts he would want to check are IRCds or mail servers, not http. This may present a problem. Im not disagreeing with anyone, just trying to help. Also, for the post scanning you could use something like this...

http://mirc.net/projects.php?go=1058169878&get_desc=1

It is in dialog form, so may not be very helpfull for a remote script. But if you read over it, you should be able to pick up the concept and apply it to your script. It basically opens a socket on a port, and if it's successful, it returns Open, if it's not, Closed.

Good luck.

Last edited by HAMM3R; 21/12/05 06:30 PM.

-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
It doesn't take a genius to change the checkhost alias slightly, so that it tries to connect to the port that you specified :rolleyes:

; /checkhost <host> <port>

Code:
alias checkhost {
  var %sock = $+(checkhost,$ticks,$r(11111,99999))
  sockopen %sock $1 $$2
  sockmark %sock $1-
}
 [color:red]  [/color] 
on *:sockopen:checkhost*:{
 [color:red]  [/color] 
  tokenize 32 $sock($sockname).mark $sock($sockname).ip
 [color:red]  [/color] 
  ; $1 = host
  ; $2 = port
  ; $3 = ip (only filled if connection successful)
 [color:red]  [/color] 
  if ($sockerr) {
    ; code if host is not alive on port
  }
  else {
    ; code if host is alive on port
  }
  sockclose $sockname
}


Gone.

Link Copied to Clipboard