|
We could define the script in the new task creation process of the Scheduler, but we'll do it independantly to clearly distinguish between the two.
As mentioned, the script takes control after the connection to the site has been established, so you have to define a script within a site profile. This has many advantages, including greatly simplifying the script language structure. The biggest advantages, though, are that the script doesn't need any connection instructions and you don't have to re-enter your server address, username, and password.
Let's define a script that will perform two transfers–one upload, one download. It will first download all HTML files from a Web site (so you get a local copy of files that could have been modified by others) and then change the remote directory (folder) and upload a file named backup.zip, which could be a backup of important files from your home computer.
Select a site where you can find at least one file with the extension *.html and where you can create a directory named backup (where the script will place the Zip file). After selecting the site, go to that site's properties. Go to the Scripts section, and you'll see the following window:
The first step is to uncheck the box at the top of the window so that the fields will be active and you can define a script for the site. Then, in the Properties subsection, give a name to your script. Here, we will name it file transfers. Now we have to actually create the script.
Let's assume the default directories defined in the site profile are those we want to use. We will begin by transferring the HTML files from the server to your computer.
Click on the Add button at the bottom of the window, then select Transfer and click Copy To Left. CopyToLeft() command sould be added in the Script field.
Type *.html within the parenthesis: CopyToLeft(*.html). This will take charge of the transfer of the HTML files from your server to your computer.
Now, let's take care of the second part–uploading backup.zip to the server in a directory named backup. We must first change the active remote directory. Go to the Add/Right menu and select Set Working Folder. This will generate the ChangeToFolderR() command in the Scripts field. Use backup as the parameter: ChangeToFolderR(backup). That will place us in the right folder for the upload.
Then go to the Add/Transfer menu and ask for a file transfer to the right. In the CopyToRight() command that appears, add backup.zip as the parameter: CopyToRight(backup.zip).
To fully save your script, click at the top Add button and on the bottom Apply button. Here's what your window should look like:
You can then exit the site profile window. Next we'll schedule the script's execution.
|