Saturday, February 12, 2022

Working with Batch Files


Synchronise List of files from Linux Server to Window using Batch file

@echo off
"C:\Users\mmendu\AppData\Local\Programs\WinSCP\WinSCP.com" ^
/ini=nul ^
/command ^
"open sftp://a_MMendu:P "synchronize -filemask=S_EDI_202202*.TXT local C:\Users\mmendu\Documents\UFT /app/retek/rtkstst/transport/extract" ^
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

Get the files by Masking in synchorize command

synchronize -filemask=RMS_EDI_202202*.TXT local "+FilesFolderpath+" /app/retek/rtkstst/transport/extract"

Monday, December 11, 2017

VBScript - Coding Standards

Constant Names

Constant Names 

Names of constants should be meaningful noun or noun phrases with all letters capitalized. Multiple words were separated using the underscore (_) character. 


Example: MY_VARIABLE

Function Names
Function Names (or) Module names should be meaningful words or phrases that describe the abstraction of the module.  Use nouns for object abstractions and verbs for functional abstractions.  Module names should be without spaces, in mixed case, with the first letter uppercase, and the first letter of each subsequent word capitalized.  

Boolean Function Names

Functions that return the results of a test of a Boolean condition T should be named IsT, HasT, or CanT.


Variable Names

  • Append computation qualifiers (Avg, Sum, Min, Max, Index) to the end of a variable name where appropriate.
  • Boolean variable names should contain Is which implies Yes/No or True/False values, such as fileIsFound.
  • Do not use literal numbers or literal strings, such as For i = 1 To 7. Instead, use named constants, such as For i = 1 To NUM_DAYS_IN_WEEK for ease of maintenance and understanding.

Tuesday, July 12, 2011

Scripting Techniques

There are 5 types of scripting techniques.
1. Linear
2. Structured
3. Shared
4. Data Driven
5. Keyword Driven

Thursday, October 14, 2010

Build in Functions

IsNumeric Function
IsDate Function
Year Function
Date Function
Time Function

IsNumeric Function: Evaluates whether an expression can be converted to Date or Not.
Example:
Dim MyVar, MyCheck
MyVar = 53 ' Assigns a Numeric value.
MyCheck = IsNumeric(MyVar) ' Returns True.
MsgBox MyCheck
MyVar = "459.95" ' Assigns a String which consists of Number
MyCheck = IsNumeric(MyVar) ' Returns True.
MsgBox MyCheck
MyVar = "45 Help" ' Assigns a String.
MyCheck = IsNumeric(MyVar) ' Returns False.
MsgBox MyCheck

IsDate Function: Evaluates whether an expression is a number or not.
Example:
Dim MyDate, YourDate, NoDate
MyDate = "October 19, 1962": YourDate = #10/19/62#: NoDate = "Hello"
Msgbox "Value of MyDate is "&IsDate(MyDate)
Msgbox "Value of Your Date is "&IsDate(YourDate)
Msgbox "Value of NoDate variable is "&IsDate(NoDate)

Year Function: Returns the whole number representing an Year
Dim MyDate, MyYear
MyDate = #October 19, 1962# ' Assign a date.
MyYear = Year(MyDate) ' MyYear contains 1962.

Date Function: Returns the current system date.
MyDate = Date
Msgbox "Today's Date is "&MyDate

Time Function: Returns the current system time.
MyTime = Time
Msgbox "Current Time is "&MyTime






Tuesday, October 5, 2010

Input Box

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.

Example:
Input = InputBox("Input Something","Title of the Input Box","Default Text in the Input Box")
Msgbox ("You Entered " & Input)

Wednesday, September 29, 2010

VBScript - XML Object

Create an XML file
Inner text and Inner xml of XML file
Details of a single node

'Create an XML file
Set oXMLDoc = CreateObject("Microsoft.XMLDOM")
Set oRoot = oXMLDoc.createElement("Employees")
oXMLDoc.appendChild oRoot

Set oRecord = oXMLDoc.createElement("Employee")
oRoot.appendChild oRecord

Set oSSN = oXMLDoc.createElement("SSN")
oSSN.Text = "123456789"
oRecord.appendChild oSSN

Set oName = oXMLDoc.createElement("Name")
oName.Text = "Thanvi"
oRecord.appendChild oName

Set oDOB = oXMLDoc.createElement("DOB")
oDOB.Text = "2009-19-06"
oRecord.appendChild oDOB

Set oSalary = oXMLDoc.createElement("Salary")
oSalary.Text = 1000000
oRecord.appendChild oSalary

Set oIntro = oXMLDoc.createProcessingInstruction("xml","version='1.0'")
oXMLDoc.insertBefore oIntro,oXMLDoc.childNodes(0)
oXMLDoc.Save "C:\Employees.xml"


'Get the Inner text and Inner xml of the XML file
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = "false"
oXML.load("C:\Employees.xml")
msgbox "XML of the file "&oXML.xml
msgbox "Inner text of the xml file "&oXML.text

'Get the details of a single node
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = "false"
oXML.load("C:\Employees.xml")
Set MyNode = oXML.SelectSingleNode("/Employees/Employee/Name")
Msgbox "XML of the single Node "&MyNode.xml
Msgbox "Inner Text of the single Node "&MyNode.text
Msgbox "Type of the Node "&MyNode.nodeType

'Set the Attribute for the XML
Set oXMLDoc = CreateObject("Microsoft.XMLDOM")
Set oRoot = oXMLDoc.createElement("suite")
oRoot.setAttribute "name","suite"
oRoot.setAttribute "parallel","classes"
oRoot.setAttribute "thread-count","3"
oXMLDoc.appendChild oRoot
Set oRecord = oXMLDoc.createElement("test")
oRecord.setAttribute "name", "test"
oRoot.appendChild oRecord
Set oClasses = oXMLDoc.createElement("classes")
oRecord.appendChild oClasses
Set oName = oXMLDoc.createElement("class")
oName.Text = "Authorization"
oClasses.appendChild oName
Set oIntro = oXMLDoc.createProcessingInstruction("xml","version='1.0'")
oXMLDoc.insertBefore oIntro,oXMLDoc.childNodes(0)
oXMLDoc.Save "G:\TestNG.xml"

Tuesday, September 21, 2010

Sample Scripts

'Using Integer Array
A(0) = 10
A(1) = 20
A(2) = 30
For i = 0 to 2
msgbox A(i)
Next

'Using String Array
StringArray(0) = "ArrayVariable1"
StringArray(1) = "ArrayVariable2"
StringArray(2) = "ArrayVariable3"
For i = 0 to 2
msgbox StringArray(i)
Next

'Split a string
Dim StringName, SplitString
StringName = "My name is xxx. I studied 10th class. I completed intermediate"
SplitString = split(StringName, " ")
For i = 0 to ubound(SplitString(i))
msgbox SplitString(i)
Next
'or
For i = LBound(SplitString) to UBound(SplitString)
msgbox SplitString(i)
Next

' Gets the Current Date, Current Time
Dim TodaysDate, CurTime, CurDateTime
TodaysDate = Date
CurTime = Time
CurDateTime = Now
msgbox "Today's Date "&TodaysDate
msgbox "Current Time "&CurTime
msgbox "Current Date and Time "&Now