Solved

ws ftp 12 script tool

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Connect to wifi using GPO 6 62
RIP Routing 5 48
printer shows as offline while connected to vpn 13 39
cisco switch stacking 6 35
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now