How to run a dos command in win7 console by newlisp

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
lyl
Posts: 44
Joined: Sun Mar 25, 2018 5:00 am

How to run a dos command in win7 console by newlisp

Post 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.

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

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

Post 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.

lyl
Posts: 44
Joined: Sun Mar 25, 2018 5:00 am

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

Post by lyl »

Perfect explanation! I learn a lot. Many thanks!

Locked