shadowcode

Need help with #include <FTPEx.au3>

14 posts in this topic

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 .

 

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 if i want to make a directory with  _FTP_CreateDir  with computer name and $date  how should i proceed ?  does the above code seem ok 

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  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

Share this post


Link to post
Share on other sites

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

_ftp_DirCreate: error -1 ocured

Edited by shadowcode

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  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

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I did itttttttt thank you very very much 

Edited by shadowcode

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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