Page 1 of 1

How to run a dos command in win7 console by newlisp

Posted: Fri May 03, 2019 11:51 am
by lyl
I want to run the dos command in win7 console by newlisp "exec" to clear secreen like this:

Code: Select all

(exec "cls")
but fails with a feedback ("\f").
Why? And how to deal with this?

PS: Also

Code: Select all

 (exec "color 0b") 
does not work.

Re: How to run a dos command in win7 console by newlisp

Posted: Sat May 04, 2019 3:35 am
by ralph.ronnquist
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.:

Code: Select all

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

Code: Select all

> !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

Code: Select all

(map println (exec "cls"))
(map println (exec "color 0b"))
Though, I don't use windows, so YMMV.

Re: How to run a dos command in win7 console by newlisp

Posted: Sat May 04, 2019 2:35 pm
by lyl
Perfect explanation! I learn a lot. Many thanks!