Solved

ws ftp 12 script tool

Posted on 2011-03-04
3
2,411 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 88
2 Gateways (bandwidth) - One domain 7 73
Cisco WAP POE power 28 76
Cisco switch suggestion 5 47
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

776 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