Skip to content

Instantly share code, notes, and snippets.

@madhurranjan
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madhurranjan/89d3311ef57e412e9e0e to your computer and use it in GitHub Desktop.
Save madhurranjan/89d3311ef57e412e9e0e to your computer and use it in GitHub Desktop.
Failed gofunc
go func() {
w, er := session.StdinPipe()
defer w.Close()
if er != nil {
fmt.Println("doesnt work ", er)
}
files, _ := ioutil.ReadDir(src)
fmt.Println(src)
fmt.Fprintln(w, "D0755 0 ", src)
// for scp'ing a file we use :fmt.Fprintln(w, "C0644", len(content), f.Name())
for _, f := range files {
fullpath := src + "/" + f.Name()
c, _ := ioutil.ReadFile(fullpath)
fmt.Fprint(w, string(c))
}
fmt.Fprintln(w, "E")
}()
if err := session.Run("/usr/bin/scp -vrt /tmp"); err != nil {
panic("Failed to run: " + err.Error())
}
Error:
/tmp/foo
panic: Failed to run: Process exited with: 1. Reason was: ()
goroutine 16 °runningé:
runtime.panic(0x18b2a0, 0xc2080007f0)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
main.main()
/Users/Madhurranjan/go/src/scp.go:81 +0x5b7
goroutine 19 °finalizer waité:
runtime.park(0x15650, 0x33e300, 0x33d629)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x33e300, 0x33d629)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
goroutine 20 °IO waité:
net.runtime_pollWait(0x711ee8, 0x72, 0x0)
/private/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/makerelease530016500/go/src/pkg/runtime/netpoll.goc:146 +0x66
net.(*pollDesc).Wait(0xc2080881b0, 0x72, 0x0, 0x0)
/usr/local/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
net.(*pollDesc).WaitRead(0xc2080881b0, 0x0, 0x0)
/usr/local/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
net.(*netFD).Read(0xc208088150, 0xc208064000, 0x1000, 0x1000, 0x0, 0x7103c8, 0x23)
/usr/local/go/src/pkg/net/fd_unix.go:232 +0x34c
net.(*conn).Read(0xc208042020, 0xc208064000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/pkg/net/net.go:122 +0xe7
bufio.(*Reader).fill(0xc20808b980)
/usr/local/go/src/pkg/bufio/bufio.go:97 +0x1b3
bufio.(*Reader).Read(0xc20808b980, 0xc2080820a0, 0x5, 0x5, 0x5, 0x0, 0x0)
/usr/local/go/src/pkg/bufio/bufio.go:175 +0x230
io.ReadAtLeast(0x712170, 0xc20808b980, 0xc2080820a0, 0x5, 0x5, 0x5, 0x0, 0x0, 0x0)
/usr/local/go/src/pkg/io/io.go:289 +0xf7
io.ReadFull(0x712170, 0xc20808b980, 0xc2080820a0, 0x5, 0x5, 0x134, 0x0, 0x0)
/usr/local/go/src/pkg/io/io.go:307 +0x71
code.google.com/p/go.crypto/ssh.(*streamPacketCipher).readPacket(0xc208082080, 0xc200000010, 0x712170, 0xc20808b980, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/cipher.go:137 +0xd8
code.google.com/p/go.crypto/ssh.(*connectionState).readPacket(0xc208003440, 0xc20808b980, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/transport.go:110 +0xe7
code.google.com/p/go.crypto/ssh.(*transport).readPacket(0xc208003440, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/transport.go:106 +0x67
code.google.com/p/go.crypto/ssh.(*handshakeTransport).readOnePacket(0xc2080940f0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/handshake.go:153 +0x105
code.google.com/p/go.crypto/ssh.(*handshakeTransport).readLoop(0xc2080940f0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/handshake.go:133 +0x27
created by code.google.com/p/go.crypto/ssh.newClientTransport
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/handshake.go:101 +0x101
goroutine 21 °chan receiveé:
code.google.com/p/go.crypto/ssh.(*handshakeTransport).readPacket(0xc2080940f0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/handshake.go:124 +0x86
code.google.com/p/go.crypto/ssh.(*mux).onePacket(0xc208088000, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/mux.go:224 +0x66
code.google.com/p/go.crypto/ssh.(*mux).loop(0xc208088000)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/mux.go:199 +0x49
created by code.google.com/p/go.crypto/ssh.newMux
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/mux.go:128 +0xee
goroutine 22 °chan receiveé:
code.google.com/p/go.crypto/ssh.(*Client).handleGlobalRequests(0xc20808c080, 0xc20806a0e0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:133 +0x4d
created by code.google.com/p/go.crypto/ssh.NewClient
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:54 +0xb6
goroutine 23 °chan receiveé:
code.google.com/p/go.crypto/ssh.(*Client).handleChannelOpens(0xc20808c080, 0xc2080c2160)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:142 +0x64
created by code.google.com/p/go.crypto/ssh.NewClient
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:55 +0xdb
goroutine 24 °semacquireé:
sync.runtime_Syncsemacquire(0xc20808c010)
/private/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/makerelease530016500/go/src/pkg/runtime/sema.goc:257 +0xc0
sync.(*Cond).Wait(0xc20808c000)
/usr/local/go/src/pkg/sync/cond.go:62 +0x9d
code.google.com/p/go.crypto/ssh.(*mux).Wait(0xc208088000, 0x0, 0x0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/mux.go:110 +0xb5
code.google.com/p/go.crypto/ssh.func·003()
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:57 +0x47
created by code.google.com/p/go.crypto/ssh.NewClient
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:59 +0x108
goroutine 25 °chan receiveé:
code.google.com/p/go.crypto/ssh.(*forwardList).handleChannels(0xc20808c090, 0xc2080c22c0)
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/tcpip.go:178 +0x73
created by code.google.com/p/go.crypto/ssh.NewClient
/Users/Madhurranjan/go/src/code.google.com/p/go.crypto/ssh/client.go:60 +0x15b
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment