After talking with a coworker it seems that "grep" returns a \n after its
output. That was the bugger keeping my initial efforts from working. Grep
was meant for "human consumption". I will need to look into buffio and
scanner as Tamas suggested.
On Friday, May 18, 2018 at 11:06:46 AM UTC-4,
After talking with a coworker it seems that "grep" returns a \n after its
output. That was the bugger keeping my initial efforts from working.
On Friday, May 18, 2018 at 11:06:46 AM UTC-4, John Fox wrote:
>
> Drilling down farther for the heck of it
>
> os/exec/exec.go
> func (c *Cmd) Output() (
Drilling down farther for the heck of it
os/exec/exec.go
func (c *Cmd) Output() ([]byte, error) { if c.Stdout != nil {
return nil, errors.New("exec: Stdout already set")
}
var stdout bytes.Buffer
c.Stdout = &stdout
captureErr := c.Stderr == nil
if captureErr {
c.Stderr = &prefixSuffi
Thank you both for the quick responses. I looked in to
https://github.com/lovoo/ipmi_exporter yesterday and saw the TrimSpace used
as well, but I am still not sure what is adding the '\n' to the commands's
Output().
Tamas, I will have to look into thebuff IO, even if I am not using this for
p
On Fri, May 18, 2018 at 12:26 PM, wrote:
> Hello all. I am creating a custom exporter for FreeNAS
> https://github.com/Maelos/freenas_exporter and am stuck on the conversion of
> the string of bytes provided by the commands output to a float. Here is my
> code, what I have tried, and my results
The input is string, so use strconv.ParseFloat, or ParseInt (will there be
non-integer number of cpus?)
Just trim the LF with strings.TrimSpace.
For production use, leave out the grep and bash, read the output lines directly
with bufio.Scanner.
--
You received this message because you are subs
Hello all. I am creating a custom exporter for
FreeNAS https://github.com/Maelos/freenas_exporter and am stuck on the
conversion of the string of bytes provided by the commands output to a
float. Here is my code, what I have tried, and my results:
What I have tried and results (commented so y