Accessing return text from exec or syscall?

Hello all,

I’ve been reading the documentation for:

https://golang.org/pkg/os/exec/
https://golang.org/pkg/syscall/

It seems none of these functions return the text from the call. For example if you do a syscall for “whoami”, I would like to see the actual return value.

Am I missing something here?

Happy Friday!

The syscall stuff is low level. Typically you would pass it a pointer to a buffer of bytes and it would fill in the value there.

Can you share some code that fails? At least os.exec should work as advertised. (I cannot comment on syscall; as @calmh already pointed out, this is pretty low-level functionality.) Check out the examples in the os.exec documentation, they show how the API is expected to be used.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.