I have an sample module
-module(helloworld). -compile(export_all). main() -> io:format("~s~s~s~n",["\e[31m","Hello world!","\e[0m"]).
When I build:
erlc helloworld.erl
After that, I run:
erl -noshell -s helloworld main -s init stop Hello world! (with red color)
erl -noshell -s helloworld main -s init stop > text.txt ^[[31mHello world!^[[0m (The content in text.txt is ugly, so I don't like).
My problem is:
- How to know when user redirect output from erlang shell into a file?
- How can I write to text.txt the content just "Hello world!" not "^[[31mHello world!^[[0m"
Thanks.