douang1243
2017-01-24 16:49
浏览 42
已采纳

使用sftp <<通过golang os / exec输入

What I want to do is exporting a file from my server via SFTP, in golang.

Here is the troubling code

cmd = exec.Command("sftp", "login@sftp.com", `INPUT
    cd /some/path
    put file.gz
    quit
    INPUT`)
cmd.Stderr = &stderr
err = cmd.Run()
if err != nil {
    fmt.Println(stderr.String())
    os.Exit(1)
}
fmt.Println("done")

It gets to done but doesn't import file.gz.

1条回答 默认 最新

相关推荐 更多相似问题