Jump to content

Need help with #include <FTPEx.au3>


Go to solution Solved by water,

Recommended Posts

Posted

Hello everyone am a  new member here and i know that  i shouldn't ask for help without giving something in return but this  one is very important for me .

i want to make something like this . i want to make a ftp script that would create a directory on the server with computer name and date something like this  

 
 
$date = @MDAY & "-" & @MON & "-" & @YEAR


 $Dir = _FTP_CreateDir(@ComputerName & "/" & $date)
   _FTP_FileSend($Server, $Username, $Password, $Save, "/" & @ComputerName & "/" & $date & "/" & $file)


the previous script doesn't  work can anyone find the mistake and help me  ??
Thank you .

 

Posted

Welcome to AutoIt and the forum!

To be able to help you we need to see the whole script. At least the part where you connect to the target server.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)
 $LogFileSize = FileGetSize($Save)
  While $LogFileSize = 100
   $Num += 1
   $Dir = _FTP_CreateDir(@ComputerName & "/" & $date)
   _FTP_FileSend($Server, $Username, $Password, $Save, "/" & @ComputerName & "/" & $date & "/" & $file)
   FileDelete($Save)
   Call("Logging")
  WEnd
WEnd
 
EndFunc   ;==>Logging
 
Func _FTP_FileSend($Server, $Username, $Password, $LocFile, $RemFile)
 
$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)
 
_FTP_FilePut($oConnect, $LocFile, $RemFile)
 
_FTP_Close($oFTP)
 
EndFunc   ;==>_FTP_FileSend
 
Func _FTP_CreateDir($DirName)
 
$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)
 
_FTP_DirCreate($oConnect, $DirName)
 
_FTP_Close($oFTP)
 
EndFunc   ;==>_FTP_CreateDir

---------------------------------------------------------------------------------------------------------
something might be wrong at this part  
 
   $Dir = _FTP_CreateDir(@ComputerName & "/" & $date)
   _FTP_FileSend($Server, $Username, $Password, $Save, "/" & @ComputerName & "/" & $date & "/" & $file)
----------------------------------------------------------------------------------------------------------------------------------------------



thank you for your reply 




 
Edited by shadowcode
Posted

You need to do some error checking.

Every function either sets a return value or the amcros @error and extended.

The _FTP* functions set @error if seomething went wrong.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

A short example (untested):

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>
$oFTP = _FTP_Open("myftp")
If @error Then Exit MsgBox($MB_ICONERROR, "Error", "_FTP_Open: Error " & @error & " occurred!")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)
If @error Then 
    MsgBox($MB_ICONERROR, "Error", "_FTP_Connect: Error " & @error & " occurred!")
Else
    _FTP_DirCreate($oConnect, $DirName)
    If @error Then MsgBox($MB_ICONERROR, "Error", "_FTP_DirCreate: Error " & @error & " occurred!")
EndIf
_FTP_Close($oFTP)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

is this  ok ? 

 
$date = @MDAY & "-" & @MON & "-" & @YEAR
 
$directory = ("@ComputerName" & "/" & $date)
 
 
 $Dir = _FTP_CreateDir($directory)  


do you think this would work ? 

is anything wrong  in my code ??
Edited by shadowcode
Posted

Did you check @error after calling _FTP_CreateDir? What is the value?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Ops, my fault.

According to the docu the return value denotes error or success. What is the value of $Dir?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

when i make it 

$dir = (@ComputerName & "-" & $date)

 it works it creates a directory with computername - date

when i make it  

$dir = (@ComputerName & "/" & $date)
it turns an error value   

i want that the date directory to be inside computername dir

 

my only problem is that i dont know how to make  dirs like  hellofolder/secondfolder/thirdfolder  inside the server 

Edited by shadowcode
  • Solution
Posted

Seems you need to create two directories. First create "@ComputerName", then make this the new current directory and then create directory "$date".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

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