Products Purchase Support Download    News About

Support - Script Examples

Automated Downloads

Script Examples
· Script Example Format
· Automated Login
· Connection Management
· Data Tables
· Debugging and Error Trapping
· Dialog Boxes
· Dynamic Data Exchange (DDE)
· Event Monitoring
· GUI Customization
· Printing
· Program Flow
· Screen Scraping
· Session Manager

Project:   Write a script to login to a host computer at a certain time of the day and download a specified file. In this example, we will wait for 2:00 AM, connect and login to a Unix system, and download a file using the Zmodem protocol.

Algorithm:   Several items need to be either configured in a stored session file, or set dynamically via script. These include the connector and relevant connection information, userid and password to login to the system, the file transfer protocol used and any related parameters, the name of file to be transferred, and if appropriate, the name of the file to be stored locally. With this information available, the necessary steps are:

  • Commands to load or set the necessary values described above.
  • A timer or time-related trigger that initiates the process.
  • Commands to connect and log onto the host system.
  • Commands to tell the host to send the file, and Dynacomm to begin receiving it.
  • Commands to log out and disconnect the session.

Product used in this example:  DynaComm Connectivity Series® 9. (release 9.0.0.0)

Relevant Commands and Functions:

CONNECT — Open a session file with saved values for connector, host address, file transfer protocol, and related parameters.

See Also:

CONNECT — initiate the connection and optionally open a specified SES file
CONNECT( ) — indicates whether the session is connected
SET BINARYTRANSFERS — set the file transfer protocol
XFERCONFIG — set parameters for specified file transfer protocol
SET CONNECTION — set the connector
CONNCONFIG — set parameters for the specified connector

SET — assigns a value to a user defined variable. (Can also use the assignment operator, =)
WAIT UNTIL — Pauses execution until the specified time of day
TIME() — returns a string with the system time
TIMER RESET — resets the specified timer to zero
DATE() — returns a string with the date
SECONDS() — returns an integer with the number of seconds from a fixed date to the specified date and time
WHEN TIMER — activates when the specified time elapses

SEND — sends string to the host; may be used to send a command defined on the host to initiate the transfer on the host
FILE RECEIVE BINARY — initiates a file download in DynaComm
FILE SEND BINARY — initiates a file upload from DynaComm (not used in this example)
KERMIT commands — Remote Kermit commands used with Kermit Server
EXISTS( ) — Indicates if a file exists on local PC
FILE RENAME — Renames a local file
SEND — send commands to the host to log off.

SHOW — Display each script command as it is executed.
DISCONNECT — disconnects the session
WINDOW CLOSE — close the specified child window

A Brief Example:

SHOW
$Time = "02:00:00 AM"
$Userid = "youruserid"
$Password = "yourpassword"
$Hostfile = "data.dat"
WAIT UNTIL $time
CONNECT "Linux.SES" WINDOW %wh
WAIT STRING "login:" QUIET "00:00:04" WINDOW %wh
SEND $Userid WINDOW %wh
WAIT STRING "Password:" WINDOW %wh
SEND $password WINDOW %wh
WAIT STRING "$" WINDOW %wh
$Command = "sz " | $hostfile
SEND $command WINDOW %wh
WAIT QUIET "00:00:10" WINDOW %wh
SEND "exit" WINDOW %wh
WAIT DELAY "1"
DISCONNECT WINDOW %wh
WINDOW CLOSE %wh
RESTART

 

After defining some constants, this script sits at a WAIT UNTIL command until the specified time of day is reached and the download operation is triggered. This involves connecting the session, logging in, and sending the command to initiate the file transfer from the host side. For our case, we”ll assume the file to be retrieved is in the home directory, and the command to initiate a Zmodem download from the Unix system is “sz” followed by the filename. This initiates the file transfer from the host side. Since we are using Zmodem, the client side recognizes the file transfer and starts the download from the client side. If we were using Xmodem or Kermit or some other protocol which does not support the Autostart feature, the FILE RECEIVE BINARY command would be used to start the client side download after it had been started on the host.

This example takes the easy approach of storing the settings in a Session file called “Linux.Ses” and having the script load the file when necessary. If the settings changed, such as if the session would connect to different hosts and use different protocols, it would be more appropriate to set those values dynamically.

Finally, the WAIT QUIET command waits for the completion of the file transfer, the command is sent to exit the host, the connection is disconnected and the session window closed. The RESTART command is used to restart the script, so the WAIT UNTIL command will be active for the next download.

Further development:

  • Download several files named “filexxx” where xxx is a counting number.
  • When downloading the file, rename any existing files in the download directory having the same name. (e.g. Back up yesterday’s file.) This may entail using the DATE( ) function and renaming the file according to the date downloaded.
  • After downloading a file from the host, it can be marked Read-Only. See the SET ATTRIBUTES command.

Purchase Contact Privacy Policy Terms of Use Sitemap Blog
© 2010 FutureSoft, Inc. All Rights Reserved

 
DynaComm i:filter | Internet Filtering | Employee Internet Monitoring | Managing Internet Access | Web Filtering | Internet Monitoring | DCS
Terminal Emulation | TN 3270 | ProComm Plus Replacement | Windows Terminal Emulation | TN 5250 | DynaComm Connectivity Series | MultiView