mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
I have a program I run from mirc that scans a list of IPS and records if they are online or not. The text file output looks liek this:
Code:
Searching Hosts v.1.2a
Online Hosts listed below
10.0.0.2
10.0.0.5
10.0.0.12
Searching Complete



What I want to do is remove the three ,ines of blank space at the bottom, and the lines that are text so that I will have a text file with only IP addresses.

The reason I ask is that I then use this text file to have mirc open sockets, and identify the machines. I tried to skip the lines that have text or null but cant seem to.
Code:
alias vercheck { 
  set %rs.tmp  1 
  sockclose rs.*
  echo *** Started Rechecking.. $lines(" $+ $scriptdirscan.txt") ips to recheck
  write " $+ $scriptdirscan_rechecked.txt" *** Started Rechecking.. $lines(" $+ $scriptdirscan.txt") ips to recheck

  while ( %rs.tmp <= $lines(" $+ $scriptdirscan.txt") ) {

    if (Searching isin $read(" $+ $scriptsdirscan.txt" , %rs.tmp )) || (Online isin $read(" $+ $scriptsdirscan.txt", %rs.tmp )) || ($null isin $read(" $+ $scriptsdirscan.txt", %rs.tmp )) { 
      inc %rs.tmp
    }
    else { 
      if ($sock(rs. $+ $read(" $+ $scriptsdirscan.txt", %rs.tmp ))) { sockclose $sockname }
      sockopen rs. $+ $read(" $+ $scriptdirscan.txt" , %rs.tmp ) $read(" $+ $scriptdirscan.txt" , %rs.tmp ) 135 
      inc %rs.tmp
    }
  }
  echo *** Finished... closing all socks.. this may take a while (log: scan_rechecked.txt) 
}

when it gets to one of these lines (nto an IP address) mirc gives an error "sockopen 'insufficient parameters'". so either a way to remvoe these fom the text file (including Null lines) or a way to skip them when running the alias vercheck is what I need to accomplich. Thanks for any suggestions.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
use the condition:

if (*.*.*.* iswm <read_line>) {
... do your stuff
}
else {
... not an ip
}


-KingTomato
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
I wouldn't use *.*.*.*, a phrase could contain this pattern.
I'd rather use something more specific..
Code:
var %line = &lt;read_line&gt;
tokenize 46 %line
if (?*.?*.?*.?* iswm %line) &amp;&amp; ($1 isnum 0-255) &amp;&amp; ($2 isnum 0-255) &amp;&amp; $&amp;
  ($3 isnum 0-255) &amp;&amp; ($4 isnum 0-255) { it's an ip }
else { it's not }


..Or regex, which would be complicated, though (regex masters, please reply if the following pattern is wrong or can be optimized)..
Code:
var %re = ^(?:0*(?:2(?:[0-4]\d|5[0-5])|1?\d{1,2})(?:\.|$)){4}
if ($regex(&lt;read_line&gt;,%re)) { it's an ip }
else { it's not }


* cold edits his posts 24/7

Link Copied to Clipboard