tengo icon indicating copy to clipboard operation
tengo copied to clipboard

exec.command usage

Open JeffreyShran opened this issue 5 years ago • 1 comments

Hello,

How exactly should one correctly call an external program using Tego?

I tried to replicate the exec.command example here: https://github.com/d5/tengo/blob/master/docs/stdlib-os.md#processstate

 ~ >> cat myapp.tengo
fmt := import("fmt")
os := import("os")

cmd := exec.command("echo", ["foo", "bar"])
output := cmd.output()
fmt.println(output)

Running it returns Compile Error: unresolved reference 'exec'. I checked the Tengo code and as far as I can tell exec is a sub-function of os?

I also tried proc := start_process("ls", ["-a"], "", []) but got a similar error. Is there any other documentation or examples out there?

Thanks! :)

JeffreyShran avatar Sep 11 '20 13:09 JeffreyShran

Greetings!

I was just looking for examples of tengo. Your code is perfect. Exchange exec.Command for os.exec:

cat > myapp.tengo 

Tell me if it worked.

pedroalbanese avatar May 30 '21 23:05 pedroalbanese