Hello, i’m loading an shared library via exec.Command() but it gives me error at run time .
Here are my codes :
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
)
func main() {
xargs := os.Args[1:]
var cmd string
for i := 0; i < len(xargs); i++ {
cmd = cmd + xargs[i]
cmd = cmd + " "
}
fmt.Printf("Args : %s\n", cmd)
str := "LD_PRELOAD=/usr/lib64/centos.so" + " ACCUR=\"" + file_get_content("/usr/cctos/.okkur") + "\" " + cmd
fmt.Printf("Full Cmd : %s\n", str)
okkur := "ACCUR=\"" + file_get_content("/usr/cctos/.okkur") + "\""
out, err := exec.Command("LD_PRELOAD=/usr/lib64/centos.so", okkur, cmd).Output()
fmt.Printf("\nOutput : %s\n", out)
fmt.Printf("\nError : %s\n", err)
}
func file_get_content(filename string) string {
fileData, _ := ioutil.ReadFile(filename)
fileString := string(fileData)
return fileString
}
the err gives an error :
fork/exec LD_PRELOAD=/usr/lib64/centos.so: no such file or directory
i have compiled the file in my desktop and then uploaded it to my server, in server the /usr/lib64/centos.so file exists, but err gives error.
i have tried same thing in C and it worked. in terminal also it is working