1
0

Implements copying executable then run it on qemu

This commit is contained in:
2018-09-22 12:44:34 +00:00
parent 737eee67e0
commit a7ecd80784
2 changed files with 50 additions and 0 deletions

View File

@@ -279,3 +279,14 @@ func (q *QemuSystem) CopyFile(user, localPath, remotePath string) (err error) {
return
}
// CopyAndRun is copy local file to qemu vm then run it
func (q *QemuSystem) CopyAndRun(user, path string) (output string, err error) {
remotePath := fmt.Sprintf("/tmp/executable_%d", rand.Int())
err = q.CopyFile(user, path, remotePath)
if err != nil {
return
}
return q.Command(user, "chmod +x "+remotePath+" && "+remotePath)
}