Hello,
I have a long ways to go while learning Nim. So one of the things I do is have a playground.nim file that I play, explore and test things. Then when I sufficiently understand or have something working. Then I can copy or rewrite into a project. I am used to dynamic languages and a live environment or repl to explore in.
I have been playing with execShellCmd.
var results = execShellCmd("unzip test.zip")
echo(results)
Archive: /home/jimmie/Nim/test.zip
inflating: /home/jimmie/Nim/test.csv
#Or something from
var results = execShellCmd("ls")
doSomethingWith(results)
I want to be able to use the results. I have yet to find out how or find any documentation which helps. I may very well be overlooking such.
Any help and or pointers to help greatly appreciated.
Thanks.
Thanks. That works perfectly for what I want.
What confuses me on some of this is that when I used execShellCmd(*) it did what I wanted done. The returned value when displayed via echo(results) displayed what I wanted to use. But I see no way to get what is displayed. I do not understand why echo() can get it, but I can not.
Regardless, you got me working. Thanks.
The returned value when displayed via echo(results) displayed what I wanted to use. But I see no way to get what is displayed.
OK, now I understand what you meant by that in the other thread.
It isn't echo that's showing the stuff on the terminal from running that command. execShellCmd just returns the exit status of the run command. Think if whatever you see in the terminal as a side effect. That cannot be captured.
To capture that, you need to use execProcess as @Arrrrrrrrr said.