Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


hjohnson
2019-02-20T19:45:15Z
Hello,

I am running a COBOL program using the SSH command line task. When I have a display, it outputs the display to VisualCron's output but addes VT100 characters.

Example:
VT100Output.JPG

The "in here." is the displayed text from the program, but as you can see there are VT100 characters surrounding it. Has anyone does this before and been able to get rid of the VT100 characters? I am wanting to grab an output to compare to another after loading.

Thank you!
Sponsor
Forum information
Gary_W
2019-02-20T20:17:47Z
Can you post the actual text from STDOUT please? Are you able to run the program on the target machine using a shell that does not output ANSI vt100 codes?
hjohnson
2019-02-20T20:27:15Z
Here is the text:

(B)0
Test2


As you can see, some characters change when I copy/paste to here.

When I run in a standard command line, I run just the program. You can not see any ANSI Vt100 output in that.

Here is what the output looks like in my normal window, and how I run it.
devWindow.JPG

I am thinking it is part of our internal settings, but came here to see if there was any other feed back.

Thanks!
Gary_W
2019-02-21T02:43:45Z
Your program and/or the runcobol command most likely has commands to skip lines, position the cursor, set background and foreground colors for the output, etc as evidenced by the blank lines before the output and the red text. Your terminal emulator (the program you use to connect to the host) interprets these commands and you see the results (red text). When output is captured by Visualcron, it does not interpret, but captures and displays the codes. Ideally you would want to take care of that on the source side by editing the program or maybe write a wrapper shell script (looks like you are in a *NIX environment) that calls the runcobol command line and strips the control characters before outputting them. That is beyond this forum though.

All that said, you need to strip off the ANSI VT100 control characters. To do this, you need to know the format of those control codes. They are typically Esc-bracket, followed by an optional 2 digits, optional semi-colon, optional single digit then either an m or an H in this example, then an optional HEX 0F (paste the output into a good text editor that will let you convert the text to HEX to really see what characters you are dealing with). No problem, you just need to match all of that and replace with nothing! Also include that string at the start, open paren, B, ESC, close paren, 0. When all that is done you will be left with some blank lines so wrap that in another call to remove lines consisting of just carriage return/linefeeds. Being able to describe what you need to match is the start, converting that description to a regular expression is the next (fun) part.

Note this is somewhat specific to your example, you may encounter other codes that will require some tweaking of this regex. Make sure to document this carefully for future maintainers!

{REGEX(,Replace,{REGEX(,Replace,{TASK(PrevTask|StdOut)},(\(B\x1B\)0|\x1B\[(\d?\d?;?\d?(m|H)(\x0F)?)),)},\r\n,)}

Break down the regular expression:
( - Start a group
\(B\x1b\)0 - A string matching a literal open paren followed by a HEX1B (an ESC) then a close paren then a 0
| - OR a string matching...
\x1b\[ - ESC then literal left bracket
( - Start another group
\d?\d?;?\d? - followed by an optional digit, followed by another optional digit (vc doesn't allow the regex form of {,2} to indicate 0, 1 or 2 digits), optional semi-colon, then another optional digit
(m|H) - Followed by a small m OR a capital H
(\x0f)?)) - Followed by an optional HEX 0F and close the second and first groups

Either of those groups get replaced with NULL, then blank lines are removed leaving you with: Test2
thomas
2019-02-21T11:29:12Z
Gary

That's impressive knowledge of Cobol related stuff! How old are you, 90? 😁
Gary_W
2019-02-21T14:37:57Z
LOL! Nothing to do with COBOL actually, but the command codes sent to turn on highlighting, colors, etc and how they are interpreted (or not) by the terminal, originally for a physical terminal where multiple different types could be connected to one system or for a host program that emulates a terminal that you kids work with today 🙂 I cut my teeth on unix system III when I first started and we dealt with this all the time. For the record, It was old when learned on it. lol You had a login script that found out what terminal you were on and set the terminal type so the codes would be interpreted correctly for the terminal you were logged in on.

For fun, have a look at what an actual VT100 terminal looks like: https://en.wikipedia.org/wiki/VT100 
thomas
2019-02-21T14:50:44Z

I think I have seen terminals like that in old movies. Nice to know anyway, thx!
Gary_W
2019-02-22T15:15:01Z
Seen in old movies!? How old are you, 20? 🙂
hjohnson
2019-02-26T16:44:46Z
Gary_W your information has been very helpful. I still do have one problem, there are CRLF's at the beginning and ending of the output when I use your guide in my actual task.

Here is what the output ends up looking like. As you can see the numbers are on a separate line from the quotations.
Variable 'recordCount' was updated to: '
01483049
'

Here is what I am using to declare the variable, per your recommendation:
{REGEX(Replace|{REGEX(Replace|{TASK(84885470-3d54-4bf9-96e4-c60dce01bdbf|StdOut)}|(\x1B\(B\x1B\)0|\x1B\[(\d?\d?;?\d?(m|H)(\x0F)?))|)}|\r\n,)}

I have tried adding another set of \r\n's but to no avail do the CRLF's go away.


Thank you!
Gary_W
2019-02-26T16:55:22Z
Please post the exact output in it's entirety.
hjohnson
2019-02-26T17:02:05Z
The first post's output was from a testing task. When I implemented your suggestion into our actual job this is the output I get before the Regex Replace:

(B)0
01483049


There is an extra [24;1H that was not in the test job. We tried replicating this in the test job and could not to any avail. Your suggestions have been extremely helpful as I have been working on this for a few week now!

Thank you!
Gary_W
2019-02-26T18:15:31Z
The latest output has an escape (x1B) at the start. I just added it to my original answer and that took care of it. Note a special case is in use here that was not in your example above. The pipe symbol is used as a separator by visualcron in functions. The pipe though means OR in the regex "language". In order to use a pipe in a regex without confusing VC, VC allows you to use any character as a separator, you just need to put it in front of the function name (Replace in this case), then use that character where you would normally use the separator. Below I use a comma as the separator. Replace my job variable with your task's Stdout and you should be ok.

{REGEX(,Replace,{REGEX(,Replace,{JOB(Active|Variable|gcw)},(\x1B\(B\x1B\)0|\x1B\[(\d?\d?;?\d?(m|H)(\x0F)?)),)},\r\n,)}

If you are just looking for 8 digits in a row you can make life easier by just matching that:

{REGEX(,Match,{JOB(Active|Variable|gcw)},\d{8})}

EDIT: For the sake of completeness, here's what your text looks like when pasted into Gvim, which shows the control characters. It makes it easy to see every character you need to match.
UserPostedImage
Scroll to Top