mIRC Home    About    Download    Register    News    Help

Print Thread
#27102 30/05/03 09:20 PM
Joined: May 2003
Posts: 2
G
gonzo Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
G
Joined: May 2003
Posts: 2
I tried using $ip identifier but it only works if connected to a server. Do you know a tip to easyly get your own ip without $ip.
Thx for future answers


MaDMAn
#27103 30/05/03 09:27 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
If you use Win 9x (95/98/ME):
start | run | winipcfg

If you use Win NT (Nt4/2k/XP):
start | run | cmd /K ipconfig

#27104 30/05/03 10:02 PM
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
type /localinfo and that will update it to your real ip address
(that what mirc does every time he connects to a server)

#27105 30/05/03 10:11 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
mirc has a gender? cool.

Quote:

(that what mirc does every time he connects to a server)


-KingTomato
#27106 30/05/03 11:34 PM
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
it*, whatever

#27107 31/05/03 01:41 AM
Joined: May 2003
Posts: 177
P
Vogon poet
Offline
Vogon poet
P
Joined: May 2003
Posts: 177
I need the same thing, but I need an identifer to automatically retrieve my IP address no matter if I'm connected to a server or not. /localinfo doesn't always work either. Sometimes it does nothing. Perhaps someone could whip a *cough* COM Object script that could do this. It would be greatly appreciated!

#27108 31/05/03 02:48 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If you're on XP, try this:
Code:
alias myip {
  var %a = run $+ $ticks 
  .comopen %a WScript.Shell 
  if $comerr { return }
  if $com(%a,Run,3,bstr,cmd.exe /c ipconfig > " $+ $mircdiripconfig.txt",uint,0,bool,true) {
    .comclose %a
    return $gettok($read(ipconfig.txt,nw,*ip address*),-1,32) 
  }
  .comclose %a
}
Just use $myip

Unfortunately I don't have 98/ME and I don't even know whether winipcfg has a command-line interface. Maybe somebody else can check this and paste winipcgf's output (if any) so we can figure out what to put in $read().


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#27109 31/05/03 03:44 AM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
You can make winipcfg output to a file doing:

winipcfg /batch file.name:

winipcfg.exe /batch ip.txt
$gettok($read(ip.txt,nw,*ip address*),$numtok($read(ip.txt,nw,*ip address*),32),32)

After having written to ip.txt, the gettok line pasted there will correctly return the IP address.

#27110 31/05/03 12:34 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Ah that's nice. The $gettok($read(ip.txt,nw,*ip address*),$numtok($read(ip.txt,nw,*ip address*),32),32) is actually the same as $gettok($read(ip.txt,nw,*ip address*),-1,32), which is what my script already has for ipconfig. So, all it needs is an OS check to run the appropriate program:
Code:
alias myip {
  var %a = run $+ $ticks 
  .comopen %a WScript.Shell 
  if $comerr { return }
  if $com(%a,Run,3,bstr,$iif($os isin 9598ME,winipcfg /batch,cmd.exe /c ipconfig >) " $+ $mircdirip.txt",uint,0,bool,true) {
    .comclose %a
    return $gettok($read(ip.txt,nw,*ip address*),-1,32) 
  }
  .comclose %a
}


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#27111 31/05/03 04:09 PM
Joined: May 2003
Posts: 177
P
Vogon poet
Offline
Vogon poet
P
Joined: May 2003
Posts: 177
I don't know anything about scripting COM Objects, but is the second .comclose needed at the end of the script? You already closed it before returning the value. Why do you need to do it again?

This seems to work just fine:

Code:
alias myip {  
  var %a = run $+ $ticks   
  .comopen %a WScript.Shell   
  if $comerr { return }  
  if $com(%a,Run,3,bstr,$iif($os isin 9598ME,winipcfg /batch,cmd.exe /c ipconfig >) " $+ $mircdirip.txt",uint,0,bool,true) {    
    [color:red].comclose %a[/color]    
    return $gettok($read(ip.txt,nw,*ip address*),-1,32)   
  } 
}

#27112 31/05/03 04:22 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Because it's possible that $com() returns 0 (which means an error occured AFTER the COM communication was established). In this case, the script will leave the connection open, wasting resources. The 2nd .comclose is definitely needed.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard