FTP Question

Just starting out? Need help? Post your questions and find answers here.
tbohon
User
User
Posts: 42
Joined: Sat Nov 22, 2008 4:22 am
Location: Olympia, WA USA

FTP Question

Post by tbohon »

Trying to learn the PB FTP commands a few at a time and having an issue with the following (highly modified sample program) code:

Code: Select all


InitNetwork()

If OpenFTP(0, "server", "userID", "password", 0)

  SetFTPDirectory(0, "/interface")
  SetFTPDirectory(0, "ftp")
  SetFTPDirectory(0, "prod")
 
  CurrDir$ = GetFTPDirectory(0)
  
  Debug "Current directory on remote server is " + CurrDir$
  
  Debug "Remote directory listing is as follows:"
  
  If ExamineFTPDirectory(0)
      While NextFTPDirectoryEntry(0)
        Debug FTPDirectoryEntryName(0)
      Wend
  EndIf
  
  CloseFTP(0)
  
Else
  MessageRequester("Error", "Can't connect to the FTP server")
EndIf

Output in the Debug window is just the two Debug print statements - the current directory and the 'Remote directory listing is as follows:' ones. The Directory listing itself from within the if-while loop doesn't show anything. I would also note that the while-if loop is from one of the documentation samples.

What am I doing wrong???

Tnx.

Tom
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: FTP Question

Post by infratec »

Hi Tom,

for me it works if I remove the ',0' in the OpenFTP() command:

Code: Select all

If OpenFTP(0, "server", "userID", "password")
else I got an error.

Bernd
tbohon
User
User
Posts: 42
Joined: Sat Nov 22, 2008 4:22 am
Location: Olympia, WA USA

Re: FTP Question

Post by tbohon »

Bernd:

Thanks for the assist - when I remove that last zero it also works just fine for me.

Guess I'm confused since that line, other than the specifics for the server and login data, was lifted verbatim from the ftp.pb file in the PureBasic examples folder:

Code: Select all


; ------------------------------------------------------------
;
;   PureBasic - Ftp example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

InitNetwork()

If OpenFTP(0, "127.0.0.1", "test", "test", 0)


Guess I'm missing something really subtle huh ? :?

Again, thanks for the assist - I'll move onward now.

Best,

Tom
Post Reply