Author Topic: IP address...  (Read 13557 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
IP address...
« on: March 02, 2005, 10:00:27 PM »
ok..

there is another one..
Can we get the IP address in LISP ??

some command like (vl-getip)  ??


 :lol:
Keep smile...

TR

  • Guest
IP address...
« Reply #1 on: March 02, 2005, 10:13:29 PM »
Not 100% sure but try doslib.

http://www.mcneel.com/doslib.htm

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #2 on: March 03, 2005, 12:30:02 AM »
I've been using a small dll I wrote years ago in VB that encapsulates a number of network related API calls. I can call it from Visual LISP.

See www.vbnet.mvps.org.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
IP address...
« Reply #3 on: March 03, 2005, 08:24:14 AM »
Quote from: Tim Riley
Not 100% sure but try doslib.

http://www.mcneel.com/doslib.htm


Yes, I know...
but i forgot to tell that i don'T want to load an ARX just for adding a simple line in LISp...
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
IP address...
« Reply #4 on: March 03, 2005, 08:27:46 AM »
Quote from: MP
I've been using a small dll I wrote years ago in VB that encapsulates a number of network related API calls. I can call it from Visual LISP.

See www.vbnet.mvps.org.



sorry..but same thing with DLL...
just need to know if there is a command or variable in LISP.
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #5 on: March 03, 2005, 08:56:47 AM »









:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
IP address...
« Reply #6 on: March 03, 2005, 06:00:01 PM »
Quote from: MP



:)




Sorry,...but don't want to load anything else that the LISP file..
so in VBA need to load VBA module.. (VBALOAD)   see ?
Keep smile...

kozmos

  • Newt
  • Posts: 114
IP address...
« Reply #7 on: March 04, 2005, 08:18:37 AM »
you can add a .dvb file into VLX as resource file while compile and then load the dvb in runtime
KozMos Inc.

SMadsen

  • Guest
IP address...
« Reply #8 on: March 04, 2005, 10:04:32 AM »
Here's a lisp you can tweak into getting some IP's

Code: [Select]
(defun IPReport (/ ws fn fp ln)
  (setq ws (vlax-get-or-create-object "WScript.Shell")
        fn (strcat (getenv "SystemDrive") "\\ipid.txt"))

  (vlax-invoke-method ws "Run" (strcat "%comspec% /c ipconfig /all >> " fn))

  (cond ((findfile fn)
         (setq fp (open fn "r"))
         (while (setq ln (read-line fp))
           (princ ln)
           (terpri)
         )
         (close fp)
         (vl-file-delete fn)
        )
  )
  (vlax-release-object ws)
  (princ)
)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #9 on: March 04, 2005, 01:43:29 PM »
Good one Stig, I forgot about that technique.

Note: If one uses the redirected ipconfig output be careful when parsing the ipaddress -- the ipconfig output format changes slightly between Windows versions.

This works under Windows 2000, not sure about other Windows versions:

Code: [Select]
(defun GetIPAddress ( / cmdecho tempfile handle stream result  )

    (setq cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)

    (command ".shell"
        (strcat "ipconfig > "
            (setq tempfile
                (vl-filename-mktemp "ipconfig.txt")
            )            
        )
    )
   
    (setvar "cmdecho" cmdecho)
   
    (cond
        (   (setq handle (open tempfile "r"))
            (vl-catch-all-apply
               '(lambda ()
                    (while (setq stream (read-line handle))
                        (cond
                            (   (wcmatch
                                    (setq stream (strcase stream))
                                    "*IP ADDRESS*"
                                )
                                (setq result stream)
                                (exit)
                            )    
                        )
                    )
                )
            )    
            (close handle)
        )    
    )
   
    (if result
        (vl-string-trim " "
            (vl-list->string
                (cdr
                    (member 58
                        (vl-string->list result)
                    )
                )
            )    
        )    
    )    
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #10 on: March 04, 2005, 01:49:25 PM »
A friend just confirmed it works under Windows XP Pro.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

SMadsen

  • Guest
IP address...
« Reply #11 on: March 04, 2005, 03:10:45 PM »
Somehow I couldn't get ipconfig to write to a file with the wscript method. That's why I did the %comspec% call. It worked.
Of course, the SHELL command hovered right over my head without ever touching down  Heh
Thanks for the reminder, Michael.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
IP address...
« Reply #12 on: March 04, 2005, 03:15:39 PM »
Funny, when I saw the use of wscript I thought "That's great, no more momentary dos window flash", but it still appears, so I thought shell would be just as effective; maybe a smidge faster. Still wscript, file system object etc. are good tools for the box.

Thanks for the initial idea Stig, have a great weekend.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
IP address...
« Reply #13 on: March 05, 2005, 07:49:02 PM »
hey...this is cool..

but how can i run this witout the DOS screen ?
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
IP address...
« Reply #14 on: March 05, 2005, 08:08:03 PM »
Not really off topic ..

Has anyone had difficulty using WScript with regard to Virus Scanners ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.