Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neither method after Connect and Login works #8

Open
wzup opened this issue Aug 15, 2015 · 3 comments · Fixed by VincenzoLaSpesa/goftp#1
Open

Neither method after Connect and Login works #8

wzup opened this issue Aug 15, 2015 · 3 comments · Fixed by VincenzoLaSpesa/goftp#1

Comments

@wzup
Copy link

wzup commented Aug 15, 2015

All these methods throw 230 error:

ftp.Cwd("/")
ftp.Pwd()
ftp.List("/")

I want to connect to IMDB ftp, ftp://ftp.fu-berlin.de. I'm trying to use your package.

Here is an example of the error:

$ read_db
List Error
panic: 230 FTP.FU-Berlin.DE login ok.


goroutine 1 [running]:
main.main()
        C:/Users/user/sbox/go/src/bitbucket.org/wzup/read_db/readDb.go:51 +0x47b

Here is my code, just a copy/paste of your example:

package main
import (
    "fmt"
    "github.com/dutchcoders/goftp"
)
func main() {

    /**
     * dutchcoders/goftp
     */
    var err error
    var ftp *goftp.FTP

    // For debug messages: goftp.ConnectDbg("ftp.server.com:21")
    if ftp, err = goftp.Connect("ftp.fu-berlin.de:21"); err != nil {
        fmt.Println("Connect Error")
        panic(err)
    }

    defer ftp.Close()

    if err = ftp.Login("admin", "sdkjcfnjoindsio"); err != nil {
        fmt.Println("Login Error")
        panic(err)
    }

    if err = ftp.Cwd("/"); err != nil {
        fmt.Println("Cwd Error")
        panic(err)
    }

    var curpath string
    if curpath, err = ftp.Pwd(); err != nil {
        fmt.Println("Pwd Error")
        panic(err)
    }
    fmt.Printf("Current path: %s", curpath)

    var files []string
    if files, err = ftp.List("/"); err != nil {
        fmt.Println("List Error")
        panic(err)
    }
    fmt.Println(files)
}

What do I do wrong? Why I cannot get an access to ftp server and see and download its contents?

@zaz600
Copy link
Contributor

zaz600 commented Jan 2, 2016

server sent multiline response with blank line before

230 FTP.FU-Berlin.DE login ok.

This line break reading lines when match blank line https://github.com/dutchcoders/goftp/blob/master/ftp.go#L282

when then you send Cwd you recive unexpexted 230 FTP.FU-Berlin.DE login ok.

That's why :)

@zaz600
Copy link
Contributor

zaz600 commented Jan 2, 2016

@VincenzoLaSpesa why did you skip response lines with len <4 ?

@VincenzoLaSpesa
Copy link
Contributor

Because the ftp standard says that a response should begin with 3 digit, than a space, then the message as a string.

Try your server with
https://ftptest.net/

You'll get an:

Error: Reply too short. Expecting 3 digit reply code followed by space followed by description

That server is not standard.

I'll try to make it work on my fork (https://github.com/VincenzoLaSpesa/goftp)
I have a new "uglyServer" to test.

zaz600 added a commit to zaz600/goftp that referenced this issue Jan 3, 2016
rewrite multiline code to fix dutchcoders#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants