Example of using STDIN and STDOUT with VBScript

Written by James McDonald

May 22, 2012

Creating a filter for Formtrap Forms Server to modify a barcode passed in from the ERP system.

launch it with

cscript.exe //nologo scriptname.vbs

Here is the script

'takes print stream and strips batch suffix to leave YDDD

' don't muck around read the entire STDIN in one go
input_file = Wscript.StdIn.ReadAll

' get a reference to STDOUT
Set objStdOut = WScript.StdOut

' my input streams lines are Unix style so split at new lines \n vbLf
input_array = split(input_file, vbLf)

array_ubound = ubound (input_array) 

for i = 0 to array_ubound

        ' i'm looping through the lines in the input stream
        ' and chopping out characters 233 and 234 of each line
	left_input = left(input_array(i), 252)
	right_input = mid(input_array(i), 255)

        ' write it back out STDOUT
	objStdOut.write left_input & right_input

        ' on the last line don't append a line feed, \n, chr(10)
	if i <> array_ubound then objStdOut.write vbLf

next

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...