Jump to content
chain

TCL Resolve hostnames

Recommended Posts

  • Administrators
Posted
# Cmd Resolve by Jeff Fisher (guppy@eggheads.org)

bind dcc -|- resolve resolve_cmd
bind dcc -|- dns resolve_cmd

proc resolve_cmd {hand idx arg} {
  if {[scan $arg "%s" hostip] != 1} {
    global lastbind
    putidx $idx "Usage: $lastbind <host or ip>"
  } else {
    putidx $idx "Looking up $hostip ..."
    set hostip [split $hostip]
    dnslookup $hostip resolve_callback $idx $hostip
  }
  return 0
}
proc resolve_callback {ip host status idx hostip} {
  if {![valididx $idx]} {
    return 0
  } elseif {!$status} {
    putidx $idx "Unable to resolve $hostip"
  } elseif {[regexp -nocase -- $ip $hostip]} {
    putidx $idx "Resolved $ip to $host"
  } else {
    putidx $idx "Resolved $host to $ip"
  }
  putcmdlog "#[idx2hand $idx]# resolve $hostip"
  return 0
}
loadhelp cmd_resolve.help

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...