#1
|
|||
|
|||
LISP Command -- Copy File
In a lisp program I have the following line to copy a file to a new name in the same folder. It doesn't work. What is the correct format?
(sd-sys-exec "cp C:/tmp/profilexy_restart C:/tmp/profilexy_restart2") Thanks, Gary |
#2
|
||||
|
||||
Re: LISP Command -- Copy File
"cp" is UNIXese - you probably have Cygwin or some other UNIX toolset installed on your system, and want to execute them via sd-sys-exec.
sd-sys-exec will always execute the specified command via cmd.exe, i.e. any syntax that works in a DOS shell window, will also work in sd-sys-exec. "cp.exe" may not, depending on whether "cp.exe" is in a directory that is listed in PATH. Anyway, the DOS equivalent of "cp" is "copy", and it's just as simple to use as "cp.exe". But then, you don't need to go through any of this platform-dependency mess. Here's a MUCH better approach: Code:
(oli:sd-copy-file "C:/tmp/profilexy_restart" "C:/tmp/profilexy_restart2") Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#3
|
||||
|
||||
Re: LISP Command -- Copy File
Hi
I have a similar question about this thread: I need to delete a temporary file made by my lisp: the file name is "C:\temp\1.mi" "sd-delete-file" doesn't exists, so I think I have to use: Code:
(oli:sd-sys-exec "del C:\temp\1.mi") Can I have some help, please? Thanks in advance Ukawa |
#4
|
|||
|
|||
Re: LISP Command -- Copy File
Quote:
In your particular case above, the lisp interpreter reads the characters following the backslashes as regular characters (which they are, in this case). So "del c:\temp\1.mi" gets changed by the lisp interpreter to "del c:temp1.mi" -- does this make sense? To include the backslashes in the string, you need to "escape" the backslashes themselves i.e. we need to use *two* of them! so using "del c:\\temp\\1.mi" should work for you. And while sd-delete-file does not exist, there is a standard lisp function delete-file that should do what you need. If you're going to use it, you need to put the filename in quotes, and if you're going to use backslashes, you will again need to escape them. However, using forward slashes will work nicely (and is usually more convenient as well). I always prefer using forward-slash notation. So Code:
(delete-file "c:/temp/1.mi") or (delete-file "c:\\temp\\1.mi") I hope this makes sense... Good luck! andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#5
|
||||
|
||||
Re: LISP Command -- Copy File
Wow, thanks for the quick responses, your explanation is extremely clear and useful.
Both the solutions work perfectly. Once again, I forgot we have modeling lisp language, AS WELL AS standard lisp language. However, thanks so much, I have really appreciated your help. Best Regards Ukawa |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|