How to run a dos command in win7 console by newlisp

Started by lyl, May 03, 2019, 04:51:43 AM

Previous topic - Next topic

lyl

I want to run the dos command in win7 console by newlisp "exec" to clear secreen like this:
(exec "cls")
but fails with a feedback ("f").

Why? And how to deal with this?



PS: Also (exec "color 0b") does not work.

rrq

#1
Presumably the terminal control is done by writing control codes to stdout, and in that case you should rather use ! instead of exec. I.e.:
(! "cls")
(! "color 0b")

Alternatively at the interactive prompt, you can type the commands without parentheses and quoting by starting with the exclamation mark
> !cls
> !color 0b

The exec function runs a sub command and gathers its output lines into a list of strings, so to make this work with exec, you would need to print out those strings. Perhaps like this
(map println (exec "cls"))
(map println (exec "color 0b"))


Though, I don't use windows, so YMMV.

lyl

#2
Perfect explanation! I learn a lot. Many thanks!