Author Topic: Lisp to run external command  (Read 8331 times)

0 Members and 1 Guest are viewing this topic.

pmvliet

  • Guest
Lisp to run external command
« on: December 08, 2004, 10:45:50 AM »
Hi Guys,

I am trying this and not having any real luck.
What I am trying to do is start a batch routine (*.bat) via lisp.
So far I have come up with:
Code: [Select]

(defun c:tr()
(command "start" "i:\\standards\\retail\\lowes\\lowes.bat" ))


This opens a command window and runs the batch but leaves the window open. I would like to have the window close.

In reading the help it says I can use the run command but this creates a line in your acad.pgp file. I would like it to be via lisp. The example of this in the help is:
Code: [Select]

Run, cmd /c,0,*Batch file to run: ,

The /c closes the window

Would I use startapp?
Any help or tidbits would be appreciated.

Thanks,
Pieter

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Lisp to run external command
« Reply #1 on: December 08, 2004, 10:52:18 AM »
Just a guess.
Code: [Select]

(startspp "cmd.exe" "batch.file")
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Lisp to run external command
« Reply #2 on: December 08, 2004, 11:20:43 AM »
Found this the other day if you are interested.

Code: [Select]
If you have the Express Tools installed, you can use some of the utility functions:

(defun c:pgp ()
;; load library if not present
(acet-arxload-or-bust "acetutil.arx")
;; run notepad, waiting for completion
(acet-sys-spawn 1 "notepad" (findfile "acad.pgp"))
;; re-init PGP
(setvar "re-init" 16)
(princ)
)
--
Frank Whaley
Autodesk, Inc.
f...@autodesk.com
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Lisp to run external command
« Reply #3 on: December 08, 2004, 11:25:40 AM »
I knew I had an example somewhere.
Code: [Select]

(defun lsp-map (drive_letter db_file / cmd_call)
  (setq cmd_call
(strcat
  "cmd.exe /c dir /b /s /l "
  drive_letter ":\\*.lsp >" (chr 34)db_file(chr 34)
  )
)

  (startapp cmd_call "")
  )
TheSwamp.org  (serving the CAD community since 2003)

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Lisp to run external command
« Reply #4 on: December 08, 2004, 12:28:40 PM »
add "EXIT" to your batch file

pmvliet

  • Guest
Lisp to run external command
« Reply #5 on: December 08, 2004, 03:02:20 PM »
Mark I am guessing you mean startapp and not startspp?

Dommy, I tried "exit" but I can't get the location correct. Before the batch file and AutoCad tries to run the exit command. After the batch file and it does the same thing.

Cab I will look into what you wrote and Mark I have to learn what that actually does.

I'll work on this and get back.

Thanks,
pieter

ronjonp

  • Needs a day job
  • Posts: 7529
Lisp to run external command
« Reply #6 on: December 08, 2004, 03:31:22 PM »
Pieter,

Why don't you post the batch file you are trying to run? I just tried running one of my batch files with startapp and it worked fine?

Code: [Select]
(startapp "S:\\-AutoCAD Routines-\\Updater\\Update Lisp Routines.bat")

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Lisp to run external command
« Reply #7 on: December 08, 2004, 03:48:39 PM »
Quote from: ronjonp
Pieter,

Why don't you post the batch file you are trying to run? Ron


Yeah...what he said...

pmvliet

  • Guest
Lisp to run external command
« Reply #8 on: December 08, 2004, 04:04:27 PM »
Now that I have played with this, the following code works
Code: [Select]

(defun c:zz ()
  (startapp "i:\\standards\\retail\\lowes\\lowes.bat" )
  )


You beat me to it.

Guess I tried making it way too complicated.

here is the batch file if you are curious:
Code: [Select]

del /q "f:\autocad\fonts"
del /q "f:\autocad\plot styles"

copy /y "i:\standards\retail\lowes\fonts" "f:\autocad\fonts\*.*"
copy /y "i:\standards\retail\lowes\plot styles" "f:\autocad\plot styles\*.ctb"


What is bringing this about is a way to eliminate different profiles for the different clients I work with. This is just a trial but I believe I will be able to get it to work.

At AutoDesk University I talked with the software developers and alpha testers and told them my issue and they say there is not immediate work around. They picked my brain for about 15 minutes. That gave me this idea. I believe a solution will be coming but I don't think it will make 2006.

Thanks,
I will have more later.

Pieter