Record scp command failure message to help debugging

This commit is contained in:
Xuewei Zhang
2019-12-06 14:49:17 -08:00
parent dd37dfe12c
commit 8b98d08b5f
+6 -2
View File
@@ -159,9 +159,13 @@ func (ins *Instance) PushFile(srcPath, destPath string) error {
if ins.ExternalIP == "" {
ins.populateExternalIP()
}
return exec.Command("scp", "-o", "StrictHostKeyChecking no",
output, err := exec.Command("scp", "-o", "StrictHostKeyChecking no",
"-i", ins.SshKey,
srcPath, fmt.Sprintf("%s@%s:%s", ins.SshUser, ins.ExternalIP, destPath)).Run()
srcPath, fmt.Sprintf("%s@%s:%s", ins.SshUser, ins.ExternalIP, destPath)).CombinedOutput()
if err != nil {
return fmt.Errorf("Error running scp: %v.\nHere is the output for the command: %v", err, string(output))
}
return nil
}
// DeleteInstance deletes a GCE instance.