Jump to content

How to Read Content of Text File from FTP_SERVER


Recommended Posts

Hello. How do i create script that will connect to my FTP SERVER. And I also have a text file name greet.txt  on the server which has the words "Hello User" in it. 

How can i make my script connect to my ftp server. Read the string from the .txt file and then output the content using MSGBOX..

Below is my script which connects to the ftp_server

 

 

Link to comment
Share on other sites

Can you access to the file with an administrative share ?

I mean: \\Servername\Data

If yes it will be easy.

If not How do you access to your file ?

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Test this script:

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    Local $sServer = 'ftp.csx.cam.ac.uk' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
    Local $sUsername = ''
    Local $sPass = ''
    Local $sPath ='/pub/README'
    Local $hFile, $sText

    Local $hOpen = _FTP_Open('MyFTP Control')
    Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

    If @error Then
        MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
    Else
        $hFile=_FTP_FileOpen($hConn,$sPath)
        $sText=BinaryToString(_FTP_FileRead($hFile,9999))  ;aus Datei lesen und in Format wandeln
        _FTP_FileClose($hFile)
        MsgBox($MB_APPLMODAL, 'README: ',$sText)
     EndIf
    _FTP_Close($hConn)
    _FTP_Close($hOpen)
EndFunc   ;==>_Example

and after testing change to your needs.

Link to comment
Share on other sites

You got this MsgBox:

31__FTP_Connect.jpg.931bbe00d4ef575b2c422d6e291a585a.jpg

in my Example or in your adapted script? This error happens when connecting to server isn't possible, in my example only possible if:

  • server is down or
  • your firewall is blocking.

othercase MsgBox34_readme.jpg.b1cde040660530b98f67610f0afb2026.jpg

appears.

 

If in your script you have also to test:

  • is user correct
  • is password correct
  • are all other parameter's for _ftp_connect correct.
  • can you connect to ftp-server with a standar ftp-client?
Edited by AutoBert
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...