Running Automater Scripts through Windows Scheduler

“Automater” Tech Tip: Running Scripts From MS Windows Scheduler

In some cases you may want to have a script scheduled to run unattended at specific time. An example may be backing up IOS configurations on a nightly or weekly basis or running the pinger script to verify any-to-any connectivity. The pinger script can also be configured to only confirm connectivity between several critical locations in the network. Here, you may want to run this script more frequently, perhaps every 15 or 30 minutes.

This tech tip will explain the configuration steps needed to run a script from a Microsoft Windows system using the Windows Scheduler Utility. (Note, the TRIAL version will NOT work with Windows Scheduler). The example used for demonstration purposes will be backing up router configurations every Saturday at 2:00 AM. It is assumed the end user installation steps at the beginning of the User’s Manual were performed.

The easiest way to accomplish this is to put the command line version, of a particular script, in a windows batch file. Then, just call the batch file from the MS windows scheduler utility.

First, you will need to have a login/password file configured to store login and password information. (See the User’s Manual for more on the login/password file).If this is a production environment, it is highly recommended that the login/password file first be encrypted using the encrypt_logins utility/script. When encrypting a login/password file that will be used with scheduler, you must use the -nokey option. You can run the encrypt_logins utility from the GUI or the comamnd line.

Starting with version 4.5.0 a template batch file is provided with the installation. The template can be found in the Net-Sense template directory for each user. For Windows 7, that directory is “C:\Users\asilver\Documents\Net-Sense\templates”.

Below shows the template batch file to backup router configs using tftp (config_bkups_template_encrypted_passwords.bat). Copy this template file to the directory “C:\Users\asilver\Documents\Net-Sense\scheduled”. If the scheduled directory does not exist, create it. We’ll call the name of the copied file config_backup.bat (any filename ending in .bat will do).

A few important notes:

  • Be sure to edit this file in text only formatting using an application such as Windows Notepad.
  • The carrot (^) at the end of all lines must be present, except for the last line.
  • The Automater does not come with a TFTP Server. There are various free TFTP servers available on the web (e.g. Pumpkin or OpenTFTP)

copy_to_tftp.ncl -ulog -autodir date -nokey ^
-pw “C:\Users\asilver\Documents\Net-Sense\net-scripts\logins_encr.txt” ^
-rf “C:\Users\asilver\Documents\Net-Sense\net-scripts\rtr_list.txt” ^
-ipaddr ^
-tftproot C:/Users/asilver/tftpboot ^
-subdir rtr_configs

Here are some more details about the script arguments being used:

  • -ulog  Tells the script to create a Unique detailed log filename. Note, the -ulog argument is optional but in this case the log file would get overwritten for each subsequent run if we did not use this argument.
  • -autodir date Tells the script to automatically create a new directory to store the config files. The directory name will be in the format of MMDDYY. Each day the script is run, a new directory will be created so the older config files are not over written.
  • -pw filename This is the name of the login/password file. Note, here it is encrypted.
  • -rf filename  The file rtr_list.txt contains a list of routers or IP Addresses. One Router/IP Addresses per line. If the router name its defined in DNS or /etc/hosts file, then the name can be used in this file.
  • -ipaddr This is the IP Address of the TFTP server. In this case, the system running the script must also be the TFTP server. This is always the case when the script is using the arguments to create directories and “touch” a blank file. (Put in your IP addresses)
  • -subdir rtr_configs This is a sub-directory, under the default TFTP directory, that the configs will be saved to (Optional)
  • -tftproot C:/Users/asilver/tftpboot  This is the default TFTP directory configured on my test system. Note, your system will have a different default TFTP server directory name than this.
  • -nokey This is needed because the login/password file (logins_encr.txt) was encrypted which would normally result in the user be prompted for an encryption key. Using this option tells the script not to prompt for an encryption key. Remember, you must create the encrypted login/password file with the -nokey option, in order to use this option in a script.

Now, all that is needed is to run the batch file through Windows Scheduler:

Select Add Scheduled Task


Next, choose Browse and locate the batch file created above (i.e., config_backup.bat).  Fill out the remainder of the Windows Scheduler utility to select the time and frequency that the batch file will run.


IMPORTANT:  For the “Start In” option of the scheduler, you must put the directory where the batch file is located.