Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

Syntax:

STOP()

Remarks:

  • The parenthesis after the command name are optional.
  • To stop and close ScriptFTP use the EXIT command instead.

Command history:

This command is available from ScriptFTP 3.0.

Examples:

$result=OPENHOST("ftp.myhost.com","myuser","mypass")
 
# If result is different than OK then stop the script execution
IF($result!="OK")
    STOP
END IF
 
# Send all the files and subdirectories in C:\MyDir to the server
PUTFILE("C:\MyDir\*.*",SUBDIRS)
 
# Transfer finished, close the connection
CLOSEHOST
$result=OPENHOST("127.0.0.1","carlos","123456")
 
# If result is different than OK jump to :failed_connection
IF($result!="OK")
    GOTO :failed_connection
END IF
 
# Change current local directory
$result=LOCALCHDIR("C:\destination_dir")
IF($result!="OK")
    GOTO :failed_change_local_dir
END IF
 
# Download all the files and subdirectories to C:\destination_dir
$result=GETFILE("*.*",SUBDIRS)
 
# If result is different than OK jump to :failed_transfer
IF($result!="OK")
    GOTO :failed_transfer
END IF
 
# Transfer finished, close the connection
CLOSEHOST
 
# Done. Stop the script execution.
STOP
 
# Go here when the connection failed three times
:failed_connection
PRINT("Cannot connect to the FTP server. Stopping script execution.")
STOP
 
# Go here when got transfer errors
:failed_transfer
PRINT("Error downloading files.Stopping script execution.")
STOP
 
# Go here when got transfer errors
:failed_change_local_dir
PRINT("Cannot access C:\destination_dir. Stopping script execution.")
STOP