Delete Last Line of a File (vbscript)
8/10/10
• Leonard Amabile
This sample task will demonstrate how AutoMate can delete the last line in a text file using vbscript.
The task will invoke a vbscript that will remove the last line within a text file. The variable, varFileName, will require a valid path and file name in order for the script to function properly.
|
Export Crystal Report PDF (vbscript)
3/17/10
• Matt Hamilton
You'll need the CRAXDRT.dll added as a Reference in your basic script for this to work (Edit > References > Browse... to add). This may already exist, if you have Crystal Reports installed, as 'Crystal Reports ActiveX Designer Run Time Library...'. This does not account for a report that prompts a user for parameters.
|
Create File of a Specific Size
3/16/10
• Leonard Amabile
This sample task will demonstrate how AutoMate can create a file with a specific size using the fsutil utility.
The task will prompt for the file size and populate the appropriate variables referenced by the fsutil utility. This task can create 1GB files in less than a second.
Usage : fsutil file createnew <filename> <length>
Eg : fsutil file createnew c:\test\testfile.txt 1000
createnew
Creates a file of the specified name and size, with content that consists of zeroes.
It is important to note that the length, actually is the length in bytes, so a value of 1000, will be 1KB.
|
Delete Last Line of a File
2/10/10
• Leonard Amabile
This sample task will demonstrate how AutoMate can delete the last line in a text file.
The task will read the contents of a text file and then loop through each line and increment a counter variable. It will then loop through the contents again, decrementing the counter variable until it reaches the number of lines to delete. It will then write a new text file minus the deleted line(s).
|
Connect Terminal: Determine if Line is Busy
1/11/10
• Leonard Amabile
This sample task will demonstrate how AutoMate can determine if a telephone number is busy.
Using the Connect Terminal action, AT modem commands are sent to the modem to dial a phone number and determine if the phone number is busy.
The task is configured to use COM3. If the modem is on a different COM port, adjust the task accordingly.
Connect Terminal actions are only available in BPA7, AM7 Premium, and AM6 Enterprise.
|
Rename File to its Parent Folder Name
11/10/09
• Leonard Amabile
This sample task will demonstrate how AutoMate can rename a filename to its parent folder name.
The ExtractFilePath() function is used to extract the path from a filename.
ExtractFilePath returns the path part (including drive letter) from the filename. The path consists of all characters before the last directory separator character ('/' or '\'), including the directory separator itself. In case there is only a drive letter, that will be returned.
ExtractFilePath can be used against a literal string, i.e. %ExtractFilePath('c:\test1\test2\test3\test4.txt')% or a variable, i.e. %ExtractFilePath(AMTrigger.Filename)%.
|
Even / Odd Number Determination
9/29/09
• Leonard Amabile
This sample task will demonstrate how AutoMate can determine if a number is odd or even using 3 different methods.
Determining if a number is odd or even can be done in various ways. You could divide the number by 2 and see if there is a fraction remaining or you could use the MOD function. Either way you are performing an operation that is quite heavy for the processor (in comparison to a bitwise AND operation). Method #1 is the fastest method.
1. %(varNum AND 1)% <> 0
The bitwise AND operator performs a bitwise comparison against the number you want to test. The result is either a 0 or 1 -- 1 for odd numbers, and 0 for even numbers.
2. %(varNum mod 2)% <> 0
The MOD operator divides two numbers and returns only the remainder. Given that all odd numbers return a 1 when divided by 2, you can simply test for this result.
3. %int(varNum/2)% = %(varNum/2)%
The INT function returns the integer part of a specified number. In other words, it returns the largest integer which is less than or equal to this numeric value. For example, if varNum is 7 then it looks like 3 = 3.5 and if varNum is 6 then it looks like 3 = 3. The INT function strips off any remainders and therefore makes the equation fail if the number is an odd number.
|
Base16 Encode and Decode (vbscript)
8/8/09
• Erik Hedlund
I've implemented some vbscript functions to handle Base16 encode and decode functionality.
The attached task is implemented in Automate BPA Server as a demonstration, but the scripts should work in all editions of Automate.
There are also a couple of functions to handle byte conversion more efficiently than the built in functions.
|
Process Stat Report
7/16/09
• Akiva Miller
Task retrieves status for approximately 200 backend database processes from 15 (configurable) UNIX machines and generates web report utilizing Excel VBA which lists all processes on each backend machine in a separate column, with the 'live' processes colored green, while the 'down' processes are colored red. This task runs continuously and updates the web page every five minutes.
This task utilizes the following AutoMate actions:
Loop File Contents
Terminal Actions
FTP Actions
Excel Actions
BASIC Script
|
Create, Get, Append & Delete Environment Variable
6/24/09
• Marjo Martinez
This sample task demonstrates a variety of environment variable related procedures using the following actions:
Set Environment Variable - Sets the value of an environment variable, and optionally creates the variable if it does not exist.
Get Environment Variable - Retrieves the value of an environment variable and places it into an AutoMate variable.
Append Environment Variable - Appends text to an environment variable. Optionally, the action can populate an AutoMate variable with the resulting value.
Delete Environment Variable - Removes an environment variable.
During runtime, details regarding each step of this sample task are as follows:
1. A Set Environment Variable action creates a new environment variable of type "user" along with a value for that variable. The value being "BPATemp".
2. A 'Create Variable' action creates an AutoMate variable named "EnvironmentVarValue".
3. A Get Environment Variable action populates the AutoMate variable with the value of the newly created environment variable.
4. A 'Message Box' action displays the value of the created environment variable.
5. Another 'Create Variable' action creates a variable named "EnvironmentVarAppended".
6. An Append Environment Variable action appends text to the value of the created environment variable. The text to append is " at Network Automation". The AutoMate variable named "EnvironmentVarAppended" is populated with the text value.
7. Another 'Message Box' action displays the new value of the created environment variable after text has been appended.
8. Finally, a Delete Environment Variable action deletes the environment variable initially created in the first step.
|
Comments (3)