Jump to content
Sign in to follow this  
Hospital

FTP works, up until...

Recommended Posts

Hi guys, the script does upload the text file, but it will not read it in msgbox? 

I don't see why, and I've been trying... any idea why?

 

#RequireAdmin
#include <FTP.au3>
#include <FTPEx.au3>
$server = "ftp.stole--private"
$username = "--private"
$pass = "--private"

$Open = _FTPOpen("--private")
consolewrite( "Open: " & $Open & @crlf )
$Conn = _FTPConnect($Open, $server, $username, $pass)
consolewrite( "Connect: " & $Conn & @crlf )
;we are connected.

$Ftpp = _FtpPutFile($Conn, @ScriptDir&"\TotalPurchases.txt", "TotalPurchases.txt")
consolewrite( "Put Result: " & $Ftpp & @crlf )

; reading it
 (this is where it stops working and returns blank.)
   $ftpfileopen = _FTP_FileOpen($Conn,"\TotalPurchases.txt")
  Local $ftpfile = _FTP_FileRead($ftpfileopen,100000)
Global $convertstring = BinaryToString($ftpfile)
msgbox(1,"read",$convertstring)
$Ftpc = _FTPClose($Open)

 

Edited by Hospital

Share this post


Link to post
Share on other sites

Add error checking for_ftp_fileopen. Clearly it's failing. 

 

Editor or _ftp_fileread

Edited by kaisies

Share this post


Link to post
Share on other sites

Read the AutoIt Help file and

you should learn that the functions _FTPConnect and _FTP_FileOpen return handles meaning two different things:

If you still want to make it work you will have to modify your udf.

 

 

Share this post


Link to post
Share on other sites

This works for me:

#include <FTPEx.au3>
$server = "127.0.0.1"
$username = "Bert"
$pass = "Test"

$Open = _FTP_Open("--private")
consolewrite( "Open: " & $Open & @crlf )
$Conn = _FTP_Connect($Open, $server, $username, $pass)
consolewrite( "Connect: " & $Conn & @crlf )
;we are connected.

$Ftpp = _FTP_FilePut($Conn, @ScriptDir&"\FTP_FileRead.au3", "FTP_FileRead.au3")
consolewrite( "Put Result: " & $Ftpp & @crlf )

; reading it(this is where it stops working and returns blank.)
   $ftpfileopen = _FTP_FileOpen($Conn,"\FTP_FileRead.au3")
  Local $ftpfile = _FTP_FileRead($ftpfileopen,100000)
Global $convertstring = BinaryToString($ftpfile)
msgbox(1,"read",$convertstring)
_FTP_Close($Conn)
_FTP_Close($Open)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...