mIRC Homepage
Posted By: AWEstun how to put /trace results into variable - 02/05/08 03:50 PM
How do I go about taking the results shown by a /trace and putting (redirecting) them into a variable?
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 04:13 PM

You would have to use raw events. Check out the numerics (low 200's) at the link below.

http://www.mishscript.de/reference/raw.numidx.htm

200-210,261-262
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 04:28 PM
Thanks for your responce. It looks like possibly raw 203 is what I need. How do I put that in a variable?
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 04:33 PM

/help raw events

$1- is the replied information.

raw 203:*:echo -a $1-

Paste that in your remotes and figure which part you need.

If you only needed $2 from the reply, you could do this...
Code:

raw 203:*: {
  set %var $2
}



or if you only needed $3 from the reply, you could do this...
Code:

raw 203:*: {
  set %var $3
}



or if you wanted to keep all of the information...
Code:

raw 203:*: {
  set %var $2-
}


Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 04:40 PM
Thanks.
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 04:41 PM

Most welcome. grin
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 04:49 PM
I put 'raw 203:*: echo -a $1-' on a line by itself, but it isn't doing anything. What triggers it?
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 04:51 PM

You would have to do a /trace and that will echo the reply. Then you figure out which part of the reply you need and set it to a variable like I showed above.
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 04:57 PM
So that 'I put 'raw 203:*: echo -a $1-' in the remotes and I typed /trace name and it showed all of it. Then I changed '$1-' to just '$1', but it still showed the whole trace.
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 05:03 PM

You're still seeing the original reply because we didn't halt it. If you changed $1- to just $1 then you should see your nick echoed on a line by itself because $1 in a raw reply is always your nick so try this...

Code:

raw 203:*: {
  echo -a $2
  haltdef
}



I can't pick out exactly what you need because I'm not an oper, all I see when I try a trace is this 481 reply...

RoCk Permission Denied: Insufficient privileges

$1 = RoCk
$2 = Permission
$3 = Denied:
$4 = Insufficient
$5 = privileges

wink
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 05:10 PM
I'm still seeing the whole thing when I type /trace name
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 05:13 PM

Do you have another raw event in the same script file that could be catching the 203 event?

raw *:

raw 203:

Either of those would prevent another raw 203 from being triggered. Also try typing /raw on
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 05:18 PM
The only line in the remote.ini file is

raw 203:*: { echo -a $1 | haltdef }

and raw is on

EDIT: It appears as it isn't even triggering.
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 05:26 PM

Maybe the numeric is different on the server you're on? Try this and see if you can find out the numeric...

/debug @debug

Then do a trace and watch the @debug window and see what the numeric(s) is for the trace reply.

* RoCk heads out to lunch
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 05:54 PM
Yep. yep! That is it - server is modified. It's 205 instead of 203! So, now knowing this, how do I go about writing a lil script that executes this when a user joins the channel and I want to save this info to a file?

EDIT: something I noticed is that it still shows the servers above, but only the $4 info I echo'd.
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 07:10 PM

If you don't want to see the raw output of the trace replies, you could make a raw event for each trace numeric and haltdef it.

raw 200:*:haltdef
raw 201:*:haltdef
raw 202:*:haltdef

etc.

If you want to trace each user that joins the channel, you could do this...

Code:

on *:JOIN:#: {
  if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
  set -eu60 $+(%,didtrace.,$nick) $true
  !trace $nick
}


...and then catch the reply with your raw 205 event and do with it what you want from there.

You could replace the # with your channel name(s) if you only want it to work on a certain channel(s).

on *:JOIN:#chan1,#chan2,#chan3: {
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 09:21 PM
The raw haltdef's worked.

As for:

on *:JOIN:#: {
if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
set -eu60 $+(%,didtrace.,$nick) $true
!trace $nick
}

I dont understand the $eval string on the second line or any of the third line. Can you explain?
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 09:55 PM

If someone with the nick JACK joined the channel, it would set a variable named %didtrace.JACK to $true so if JACK joins more than one of your channels, you will still only do one trace on JACK instead of one for each channel. The variable is automatically unset in 60 seconds. You can remove it if you want, it's a flood protection.

Code:

on *:JOIN:#: {
  if ($nick != $me) !trace $nick
}

Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 10:06 PM
It wont work for me. Following is the exact remote.ini file:

;raw 200:*:haltdef
;raw 262:*:haltdef
raw 205:*: { %vname = $4 | haltdef }

;on ^*:JOIN:#: {
!trace $nick
/msg $nick Hello %vname and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
}
; this is my original script, but the trace was lagging? and it is showing the previous traced user.

on *:JOIN:#: {
if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
set -eu60 $+(%,didtrace.,$nick) $true
!trace $nick
/msg $nick Hello %vname and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
}


It appears that it isn't even getting passed the flood protection, as I'm not even seeing the raw 200 or raw 262, which are servers and trace end.
Posted By: RoCk Re: how to put /trace results into variable - 02/05/08 10:12 PM

Code:

raw 200:*:haltdef
raw 262:*:haltdef
raw 205:*: { set %vname $4 | haltdef }

/*
on ^*:JOIN:#: {
  !trace $nick
  msg $nick Hello %vname and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
}
*/
; this is my original script, but the trace was lagging? and it is showing the previous traced user.

on *:JOIN:#: {
  if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
  set -eu60 $+(%,didtrace.,$nick) $true
  !trace $nick
  msg $nick Hello %vname and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
} 


It's showing the previous traced user because it hasn't yet had time to set %vname to the new name yet before you msg $nick. You could put the message in the raw event...

Code:

raw 200:*:haltdef
raw 262:*:haltdef
raw 205:*: {
  if ($eval($+(%,didtrace.,$4),2)) msg $4 Hello $4 and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
  haltdef
}

on *:JOIN:#: {
  if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
  set -eu60 $+(%,didtrace.,$nick) $true
  !trace $nick
}


Change the first and second $4 in the raw 205 to be what ever token is the users nick.
Posted By: AWEstun Re: how to put /trace results into variable - 02/05/08 10:15 PM
So you have to do a beginning comment out and an ending comment out, instead of just commenting out any on's?

Okay that got it going, but it's still showing the current joining user, the previous user's info, as if it's lagged. Do I need to add some kind of 5-10 second timer delay?

EDIT: okay I tried a timer, but it's still showing the previous user's into to the next user.
Posted By: RoCk Re: how to put /trace results into variable - 03/05/08 12:52 AM

Did you try how I showed you in that last code of my last post?
Posted By: AWEstun Re: how to put /trace results into variable - 03/05/08 01:03 AM
So it would look something like this?

raw 205:*: {
if ($eval($+(%,didtrace.,$nick),2)) msg $nick Hello $4 and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
haltdef
}

It's not showing anything for $nick when it tries to msg $nick.

Would it be possible to 'shave' the $left side of $4 (starting from the very left and going to a [ ) and get that name? E.x. $4 = name[12345678_12345678@1.2.3.4]

If we can do that, then we'll have the exact name we need.
Posted By: RoCk Re: how to put /trace results into variable - 03/05/08 01:28 AM

Nevermind, I see what you mean .. you need $gettok()

Try this out...
Code:

raw 200:*:haltdef
raw 262:*:haltdef
raw 205:*: {
  var %nick = $gettok($4,1,91)
  if ($eval($+(%,didtrace.,%nick),2)) msg %nick Hello $4 and welcome! Today is $date (dd/mm/yyyy) and the time is $time (CST).
  haltdef
}

on *:JOIN:#: {
  if (($nick == $me) || ($eval($+(%,didtrace.,$nick),2))) return
  set -eu60 $+(%,didtrace.,$nick) $true
  !trace $nick
}


Posted By: AWEstun Re: how to put /trace results into variable - 03/05/08 01:45 AM
OMG it works!!!

Now.. smile

How do I go about saving $4 to a text file.

I want to start out simple and then eventially be able to save same screen names with different IP's and same IP's with different screen names to the file. So I can do something like right click on a name on the room and a list of all the IP's that that name has used will list and a list of all the names that that IP has used.
Posted By: RoCk Re: how to put /trace results into variable - 03/05/08 01:50 AM

You want them all in one .txt file? Add this to your raw 205 event on the line above the haltdef. Change the file name to whatever you want.

write tracenicks.txt $4
Posted By: AWEstun Re: how to put /trace results into variable - 03/05/08 02:02 AM
Where is that file stored?
Posted By: RoCk Re: how to put /trace results into variable - 03/05/08 02:08 AM

That would store it in the mirc folder or the settings folder. You could use $scriptdir to store it where the script file is...

write $qt($scriptdirtracenicks.txt) $4
Posted By: AWEstun Re: how to put /trace results into variable - 03/05/08 02:14 AM
It must be in a hidden dir under document and settings > applications data > mirc? If so how to I access that folder?

EDIT: Accessed that hidden mirc folder and made a shortcut to the folder. Looks like it's building...
Posted By: RoCk Re: how to put /trace results into variable - 03/05/08 02:20 AM

Use $mircdir

//run $mircdir
Posted By: AWEstun Re: how to put /trace results into variable - 03/05/08 02:35 AM
Okay now lets say I want to 'read' back in a 'list' of all the screennames that are the same, how would I go about that?

Format is: screenname[12345678_12345678@1.2.3.4]

Then have it output something like:
screenname is screenname[12345678_12345678]@1.2.3.4 (current) also using IPs: @5.6.7.8, @4.3.2.1, @8.7.6.5, etc.

screenname[12345678_12345678] will always stay the same, but the IP may change, especially if they log in from various locations.

This server is modified and does not let the user change their screenname or account info [12345678_12345678].
© mIRC Discussion Forums