In my python script I am trying to pass a variable to a Go binary to perform an operation and retrieve output from Go binary as variable and use it in my python script
This is my Go Program which I am using to create my binary and I am creating binary
package main
import (
"fmt"
"log"
"os"
"strconv"
ps "github.com/mitchellh/go-ps"
)
var args_pid string
var xyz int
func main() {
args_pid = os.Args[1]
first, err := strconv.ParseInt(args_pid, 10, 0)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
xyz = int(first)
pp, _ := ps.FindProcess(xyz)
log.Printf("The pid of passed process is %v
", pp.Pid())
}
This is my python script where I am using this binary
import os
args_pid = 1401
cmd = './process_pid args_pid'
so = os.popen(cmd).read()
print so
I get the following error:
strconv.ParseInt: parsing "args_pid": invalid syntax
Can someone help me resolve this issue?