|
Joined: May 2003
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
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
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
Hoopy frood
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)
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
mirc has a gender? cool. (that what mirc does every time he connects to a server)
-KingTomato
|
|
|
|
Joined: May 2003
Posts: 730
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 730 |
|
|
|
|
Joined: May 2003
Posts: 177
Vogon poet
|
Vogon poet
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!
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
If you're on XP, try this: 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
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
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.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
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: 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
|
|
|
|
Joined: May 2003
Posts: 177
Vogon poet
|
Vogon poet
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:
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)
}
}
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
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
|
|
|
|
|