Hospital

FTP works, up until...

8 posts in this topic

#1 ·  Posted (edited)

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



Check  what is in $Conn (line 19 ).

 

Share this post


Link to post
Share on other sites

I don't see what's wrong with it.

I can do FilePut with $conn but I can't FileRead?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

What did you do to "see what's wrong with it" ?

Share this post


Link to post
Share on other sites

so, this a udf problem?

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