I want to programing a function about open the file directly. Like python code:
os.system("ls")
For example, when I use this function (fun_open "/path/to/file"), the system will open the file use the default app. If file is a .txt, open it with textedit.
How to make it?
----UPDATE 9/24/2015-----
My code is:
(defun open_by_system (dir)
(sb-ext:run-program "/usr/bin/open" (list "-a" "Preview" dir)))
and I use it:
CL-USER> (open_by_system "~/Desktop/ML.pdf")
#<SB-IMPL::PROCESS :EXITED 1>
Nothing else happen
I'd recommend using UIOP, which provides portable interface to the OS and is universally available as a part of ASDF3:
See the docstrings in run-program.lisp for details.
If you need more convenience functions, you could take a look at inferior-shell.
I recommend you to take a look at the available libraries on quickdocs:
link
I recommend you to use inferior-shell available on quicklisp
link
loading:
a simple sample:
a sample with pipes:
Mac OS X and SBCL:
Open a text file in the default text editor application TextEdit:
Open the file with LispWorks as the text editor:
You might want to consult the SBCL manual for such questions. For example the chapter on Running External Programs.