How to remove special characters / escape functions using erlang os: cmd ()?

Recently, I used the os: cmd command to run commands on the local computer. When I use os: cmd. Not only do I get the output of my specified command, but the resulting lines and output produce or “insert” spaces and escape sequences in my output / line example:

os: cmd ("WMIC BIOS GET SERIALNUMBER").

It produces:

"SerialNumber \ r \ r \ nCN9B4R1 \ r \ r \ n \ r \ r \ n"

I tried searching for erlang documents, but nothing in the IO lib stretches me or rings me.

Thanks guys so much!

+3
source share
1 answer

. os:cmd/1 . , , , , - , . io_lib, string, lists re . , string:tokens\2, ,

Output = os:cmd("WMIC BIOS GET SERIALNUMBER"),
["SerialNumber", SerialNumber] = string:tokens(Output, " \r\n").
+4

Source: https://habr.com/ru/post/1680261/


All Articles