Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DOS commands in lisp

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
2873 Views, 13 Replies

DOS commands in lisp

Does anyone know where I go to learn about the "shell" command. I want to
be able to run a DOS commands from lisp.
Tom
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

ignore this test


"Tom" wrote in message
news:F46F5BD6DCE549A5623D97CCC97A68CB@in.WebX.maYIadrTaRb...
> Does anyone know where I go to learn about the "shell" command. I want to
> be able to run a DOS commands from lisp.
> Tom
>
>
Message 3 of 14
Anonymous
in reply to: Anonymous

It would be useful to see a lisp routine that someone has writen that
includes the use of DOS commands.
Thanks,
Tom
Message 4 of 14
Anonymous
in reply to: Anonymous

Here is a not very useful but perhaps instructive example.

;MAKE DIRECTORY NAME WITH SPACE CHARACTERS IN IT
(defun c:tdir ()
(command "shell" (strcat "mkdir " (chr 34) "c:\\temp\\my test1" (chr 34)))
)

--
Cliff

"Tom" wrote in message
news:FABC2365863700810B5BA394E56AE779@in.WebX.maYIadrTaRb...
> It would be useful to see a lisp routine that someone has writen that
> includes the use of DOS commands.
> Thanks,
> Tom
>
>
Message 5 of 14
BillZ
in reply to: Anonymous

Hi Tom,
Dos_lib is a free application from Mcneel.com that allows you to run dos functions seemlessly inside autolisp.
It also includes some GUI, system and printer functions.
here's asnip from one of my programs,
>>> (dos_command "sort/+7<>g:\\autolisp\\lisp_text\\nflst1.txt" 3)
<<<
Enjoy!
BillZ
Message 6 of 14
Anonymous
in reply to: Anonymous

> Does anyone know where I go to learn about the "shell" command. I want to
> be able to run a DOS commands from lisp.

What do you want to see? I've usually found it easier to write a batch
file from LISP then call the batch file using SHELL.

--
Sincerely,
Darren J. Young

Minnesota CADWorks, Inc.
P.O. Box 7293
Saint Cloud, Minnesota 56302-7293
Phone: (320) 654-9053
WWW: http://www.mcwi.com
Message 7 of 14
Anonymous
in reply to: Anonymous

the setback of using shell is lisp doesn't hold on.
if you wnat for example to create a directory sometimes it is not yet
created if you need it.


>
> What do you want to see? I've usually found it easier to write a batch
> file from LISP then call the batch file using SHELL.
>
> --
> Sincerely,
> Darren J. Young
>
> Minnesota CADWorks, Inc.
> P.O. Box 7293
> Saint Cloud, Minnesota 56302-7293
> Phone: (320) 654-9053
> WWW: http://www.mcwi.com
Message 8 of 14
Anonymous
in reply to: Anonymous

> the setback of using shell is lisp doesn't hold on.
> if you wnat for example to create a directory sometimes it is not yet
> created if you need it.

This can be solved easily a couple ways. One of the oldest tricks in the
book is to create a semaphore in disk and loop your code until it's gone.
You'r batch file would delete it after it's done processing. Of course,
there's more elegant ways to do this sort of thing now.

Another way, is to place a shortcut in your PGP file to call the shell
and set it up to have AutoCAD wait until it returns from the shell. Your
lisp would then call the shortcut.

--
Sincerely,
Darren J. Young

Minnesota CADWorks, Inc.
P.O. Box 7293
Saint Cloud, Minnesota 56302-7293
Phone: (320) 654-9053
WWW: http://www.mcwi.com
Message 9 of 14
Anonymous
in reply to: Anonymous

i know the solutions but as you said it yourself they are not the most
elegant and since there are vlisp functions there are not manny occasions
you need the dos functions

Darren J. Young schreef in berichtnieuws
MPG.16828cef320ac4b3989f83@discussion.autodesk.com...
> > the setback of using shell is lisp doesn't hold on.
> > if you wnat for example to create a directory sometimes it is not yet
> > created if you need it.
>
> This can be solved easily a couple ways. One of the oldest tricks in the
> book is to create a semaphore in disk and loop your code until it's gone.
> You'r batch file would delete it after it's done processing. Of course,
> there's more elegant ways to do this sort of thing now.
>
> Another way, is to place a shortcut in your PGP file to call the shell
> and set it up to have AutoCAD wait until it returns from the shell. Your
> lisp would then call the shortcut.
>
> --
> Sincerely,
> Darren J. Young
>
> Minnesota CADWorks, Inc.
> P.O. Box 7293
> Saint Cloud, Minnesota 56302-7293
> Phone: (320) 654-9053
> WWW: http://www.mcwi.com
Message 10 of 14
Anonymous
in reply to: Anonymous

Tom,
Here are some old routines I used to use. They are not elegant, but they
work. Now I use DOSLib or VLISP. Hope this helps.

(DEFUN DELFILE (FLIST /)
(SETQ DELFIL "C:\\DELFILE.BAT"
DFILE (OPEN DELFIL "w")
)
(WRITE-LINE "@ECHO OFF" DFILE)
(WRITE-LINE (STRCAT "ECHO Deleting " FLIST) DFILE)
(WRITE-LINE (STRCAT "DEL " FLIST) DFILE)
(CLOSE DFILE)
(COMMAND "SHELL" "C:\\DELFILE")
(PRINC)
)

(DEFUN RENFILE (RFILE1 RFILE2 /)
(SETQ RENFIL "C:\\RENFILE.BAT"
RFILE (OPEN RENFIL "w")
)
(WRITE-LINE "@ECHO OFF" RFILE)
(WRITE-LINE (STRCAT "ECHO Renaming " RFILE1 " to " RFILE2) RFILE)
(WRITE-LINE (STRCAT "RENAME " "\"" RFILE1 "\"" " " "\"" RFILE2 "\"")
RFILE)
(CLOSE RFILE)
(COMMAND "SHELL" "C:\\RENFILE")
(PRINC)
)

(DEFUN SRTFILE (SFILE1 SFILE2 /)
(SETQ SLIST NIL
SOURCE (OPEN SFILE1 "r")
SLINE (READ-LINE SOURCE)
SLIST (LIST SLINE)
COUNT 0
)
(WHILE SLINE
(SETQ SLINE (READ-LINE SOURCE)
SLINE2 (LIST SLINE)
)
(IF SLINE (SETQ SLIST (APPEND SLIST SLINE2)))
(SETQ COUNT (+ COUNT 1))
)
(SETQ SLIST (REVERSE (ACAD_STRLSORT SLIST)))
(CLOSE SOURCE)
(SETQ DESTIN (OPEN SFILE2 "w"))
(REPEAT COUNT
(SETQ COUNT (- COUNT 1)
DLINE (NTH COUNT SLIST)
)
(WRITE-LINE DLINE DESTIN)
)
(CLOSE DESTIN)
(PRINC)
)

--
Daniel J. Altamura, R.A.
Altamura Architectural Consulting
and SoftWorx, Autodesk Registered Developer
DAltamura@compuserve.com


"Tom" wrote in message
news:FABC2365863700810B5BA394E56AE779@in.WebX.maYIadrTaRb...
> It would be useful to see a lisp routine that someone has writen that
> includes the use of DOS commands.
> Thanks,
> Tom
>
>
Message 11 of 14
Anonymous
in reply to: Anonymous

Where do I find out more about visual lisp?
Tom

"Paul" wrote in message
news:4EB0D27C0C2511E3F5C220B18054402E@in.WebX.maYIadrTaRb...
> i know the solutions but as you said it yourself they are not the most
> elegant and since there are vlisp functions there are not manny occasions
> you need the dos functions
>
> Darren J. Young schreef in berichtnieuws
> MPG.16828cef320ac4b3989f83@discussion.autodesk.com...
> > > the setback of using shell is lisp doesn't hold on.
> > > if you wnat for example to create a directory sometimes it is not yet
> > > created if you need it.
> >
> > This can be solved easily a couple ways. One of the oldest tricks in the
> > book is to create a semaphore in disk and loop your code until it's
gone.
> > You'r batch file would delete it after it's done processing. Of course,
> > there's more elegant ways to do this sort of thing now.
> >
> > Another way, is to place a shortcut in your PGP file to call the shell
> > and set it up to have AutoCAD wait until it returns from the shell. Your
> > lisp would then call the shortcut.
> >
> > --
> > Sincerely,
> > Darren J. Young
> >
> > Minnesota CADWorks, Inc.
> > P.O. Box 7293
> > Saint Cloud, Minnesota 56302-7293
> > Phone: (320) 654-9053
> > WWW: http://www.mcwi.com
>
>
Message 12 of 14
Anonymous
in reply to: Anonymous

helpfiles?
Message 13 of 14
jpCADconsulting
in reply to: Anonymous

Hi folks, I've been trying to issue this DOS commadn from acad.lsp without much luck:

net config server /autodisconnect:-1

 

I'm sure it's a syntax issue, what I have is:

 

(COMMAND "SHELL" "net config server /autodisconnect:-1")

 

I think the spaces and forward slash (and maybe the 🙂 are causing issues.

Any insight is appreciated.  Thanks in advance for your help.

 

-JP

Message 14 of 14

Just an update...

I think the issue might be that in order to issue this command successfully manually, I need to run CDM "as Administrator".

Not sure there is a way to do that using SHELL in Lisp, but if there is... do tell!

 

Thanks again!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost