• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2776
  • Last Modified:

ws ftp 12 script tool

Am trying to build a script that -

logs on to an existing ws ftp remote site
opens a directory on the site
locates a file on the directory
delets the file
opens a local directory
locates a file on the directory
uploads file from local directory to server directory
closes connection

Please advise - thanks

Am using WS FTP Pro 12
0
garethtnash
Asked:
garethtnash
2 Solutions
 
ChuckDeezelCommented:
Check out this reference site. It has a good reference section.

http://support.ipswitch.com/kb/WS-20010103-DM01.htm

And here is a sample script:

http://ipswitchft.custhelp.com/app/answers/detail/a_id/446
0
 
AlexPaceCommented:
This is sort of off-topic but you might consider using Robo-FTP this sort of task.  The basic script for your workflow would looke like this:
FTPLOGON "127.0.0.1" /user="myuserid" /pw="mypassword"
FTPCD "RemoteSubDirectory"
FTPDELETE "file.old"
WORKINGDIR "c:\data\local"
SENDFILE "file.new"
FTPLOGOFF

Open in new window


So thats not really a lot different than what you would have in WS FTP but with Robo-FTP you can do error handling and reporting for every step in the process, including the ability to retry steps X number of times like this:
BEGINFUNCTIONS
 FUNCTION SendEmail body_text 
  SET from_name = "Robo-FTP" 
  SET from_addr = "roboftp@domain.com"
  SET recipient = "automationadmin@domain.com"
  SET subj = "Robo-FTP status report (do not reply)"
  SET body = "Robo-FTP statsus report:    " + %crlf + body_text 
  CREATEMAIL from_name from_addr subj body "" /nocrlf
  SENDMAIL "127.0.0.1" "" recipient 
  RETURN
ENDFUNCTION
ENDFUNCTIONS

:step1
LOOPCOUNT 3
FTPLOGON "127.0.0.1" /user="myuserid" /pw="mypassword"
LOOPIF GOTO step1 ELSE GOTO step2
SendEmail "Unable to connect to remote server after 3 tries."
GOTO done

:step2
FTPCD "RemoteSubDirectory"
IFERROR= $ERROR_SUCCESS GOTO step3
SendEmail "Unable to access sub-folder on remote site."
GOTO done

:step3
GETSITEFILE "file.old"
IFERROR= $ERROR_SUCCESS GOTO step4
; old file does not exist on remote site
GOTO step5

:step4
FTPDELETE "file.old"
IFERROR= $ERROR_SUCCESS GOTO step5
SendEmail "Unable to delete old file from remote site."
GOTO done

:step5
WORKINGDIR "c:\data\local"
IFERROR= $ERROR_SUCCESS GOTO step6
SendEmail "Unable to access local sub-folder."
GOTO done

:step6
GETFILE "file.new"
IFERROR= $ERROR_SUCCESS GOTO step7
SendEmail "Can't upload because local file does not exist!"
GOTO done

:step7
LOOPCOUNT 3
SENDFILE "file.new"
IFERROR= $ERROR_SUCCESS GOTO success
LOOPTO step7
SendEmail "Failed three tries to upload new file."
GOTO done

:success
SendEmail "The upload process completed successfully."

:done
FTPLOGOFF
EXIT

Open in new window

If this specific situation is on the high end of your automation needs then it probably isn't worth the time and effort to switch FTP platforms but if you do a lot of complex repetitive file transfers you might want to give Robo-FTP a try.  For sake of comparison here is a list of Robo-FTP script commands from the help file: http://www.robo-ftp.com/help/3.7/script_commands_grouped_by_function.htm
0
 
garethtnashAuthor Commented:
Big thanks :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now