Thanks for time in responding.
Appreciate.
On Wed, Jan 18, 2017 at 1:46 PM, roger peppe wrote:
>
>
> On 17 January 2017 at 19:14, Deepak Jain wrote:
>
>> I fixed the error by invoking Copy command with abs source path.
>>
>> srcPath, _ :=
>> e := util.Copy(srcPath, dst)
>>
>> If i could modify
On 17 January 2017 at 19:14, Deepak Jain wrote:
> I fixed the error by invoking Copy command with abs source path.
>
> srcPath, _ :=
> e := util.Copy(srcPath, dst)
>
> If i could modify into a single line
>
> util.Copy(filepath.Abs(filepath.Dir(src)), dst)
> Throws error as filepath.Abs(filepath.
On 17 January 2017 at 18:50, Deepak Jain wrote:
> Thanks for pointing to https://github.com/juju/
> utils/blob/master/fs/copy.go
>
>
> I was testing Copy function that recursively copies directories. I am able
> to copy first level of files and it creates directories. It fails to copy
> the conte
In Go, don't try to combine those actions into a single line. Also you
shouldn't ignore the error from filepath.Abs.
On Tue, Jan 17, 2017 at 11:14 AM Deepak Jain wrote:
> I fixed the error by invoking Copy command with abs source path.
>
> srcPath, _ :=
> e := util.Copy(srcPath, dst)
>
> If i co
I fixed the error by invoking Copy command with abs source path.
srcPath, _ :=
e := util.Copy(srcPath, dst)
If i could modify into a single line
util.Copy(filepath.Abs(filepath.Dir(src)), dst)
Throws error as filepath.Abs(filepath.Dir(src)) returns a tuple.
In scala i can use _1, _2 to acces
Thanks for pointing to https://github.com/juju/utils/blob/master/fs/copy.go
I was testing Copy function that recursively copies directories. I am able
to copy first level of files and it creates directories. It fails to copy
the contents within those directories.
func Copy(src, dst string) er
You don't really need to use the external cp command:
https://play.golang.org/p/F1YHzQL4UN
On 16 January 2017 at 21:35, Deepak Jain wrote:
> util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json",
> artifact.dir))
>
> func ExecuteCommandWithOuput(cmd *exec.Cmd) {
> output, err := cmd.O
On Mon, 16 Jan 2017 13:35:07 -0800 (PST)
Deepak Jain wrote:
> util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json",
> artifact. dir))
>
> func ExecuteCommandWithOuput(cmd *exec.Cmd) {
> output, err := cmd.Output()
> if err != nil {
> log.Print("Error executing ", cmd.Args, err)
> }
>
Thanks for Stderr.
I would like to do a recursive copy of a directory (similar to cp -r ),
directory can contain files (binaries or text files) and directories.
I now see
exit status 1: cp: ./*.json: No such file or directory
Code:
//ExecuteCommandWithOuput will execute cmd passed as argumen
Before answering the questions below, you should know that exec.Command
will not do shell glob expansion since it does not invoke commands via
a shell. If you want to do that you can either invoke via a shell or do
the globbing yourself with filepath.Glob[1].
1. You can capture the combined output
util.ExecuteCommandWithOuput(exec.Command("cp", "-r", "./*.json", artifact.
dir))
func ExecuteCommandWithOuput(cmd *exec.Cmd) {
output, err := cmd.Output()
if err != nil {
log.Print("Error executing ", cmd.Args, err)
}
fmt.Print(string(output))
}
Output
2017/01/16 13:26:35 Error executing [cp -
11 matches
Mail list logo