Discussion:
Executing Shell-Command and using its result?
(too old to reply)
Torsten Zuehlsdorff
2014-12-09 14:47:14 UTC
Permalink
Hello,

i want to execute a shell-command and uses its result for further
processing. How can i do this?

My core idea is a better highlighting for PHP. PHP has the function
token_get_all() which tokenize a PHP-script. I want to execute a
PHP-Script on the file of the current visible buffer, get the list of
tokens and use this list for highlighting and indentation.

Anyone an idea how to achieve this?

Thanks and Greetings from Germany,
Torsten
Ralf Fassel
2014-12-09 15:16:38 UTC
Permalink
* Torsten Zuehlsdorff <***@meisterderspiele.de>
| Hello,
| i want to execute a shell-command and uses its result for further
| processing. How can i do this?

Check 'with-output-to-string' and 'call-process'
Something along the lines of:

(defun exec-to-string (command)
"Return the output of shell command COMMAND as a string."
(with-output-to-string
(call-process "/bin/sh" nil t nil "-c" command)))

Replace the /bin/sh etc by a call to your program.

HTH
R'
Raymond Wiker
2014-12-09 17:18:12 UTC
Permalink
Post by Ralf Fassel
| Hello,
| i want to execute a shell-command and uses its result for further
| processing. How can i do this?
Check 'with-output-to-string' and 'call-process'
(defun exec-to-string (command)
"Return the output of shell command COMMAND as a string."
(with-output-to-string
(call-process "/bin/sh" nil t nil "-c" command)))
Replace the /bin/sh etc by a call to your program.
HTH
R'
shell-command and shell-command-on-region may be better
options...

Loading...