Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use sbcl to use shell command

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

like image 795
ccQpein Avatar asked Mar 14 '23 17:03

ccQpein


1 Answers

I'd recommend using UIOP, which provides portable interface to the OS and is universally available as a part of ASDF3:

(uiop:run-program "ls")

See the docstrings in run-program.lisp for details.

If you need more convenience functions, you could take a look at inferior-shell.

like image 174
Stanislav Kondratyev Avatar answered Mar 17 '23 05:03

Stanislav Kondratyev