Solved

ws ftp 12 script tool

Posted on 2011-03-04
3
2,470 Views
Last Modified: 2012-05-11
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
Comment
Question by:garethtnash
3 Comments
 
LVL 4

Accepted Solution

by:
ChuckDeezel earned 250 total points
ID: 35039856
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
 
LVL 16

Assisted Solution

by:AlexPace
AlexPace earned 250 total points
ID: 35043734
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
 

Author Closing Comment

by:garethtnash
ID: 35072841
Big thanks :)
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question