KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

HMS - SetFolderVariable - strings with spaces

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Bug reports
View previous topic :: View next topic  
Author Message
seelye



Joined: 17 Sep 2005
Posts: 40
Location: USA

PostPosted: Sun Oct 01, 2023 9:21 am    Post subject: HMS - SetFolderVariable - strings with spaces Reply with quote

OS Windows 2008 R2
HostMonitor v 14.20

The funny things is this is very similar to a "bug report" I posted in 2013.

https://www.ks-soft.net/cgi-bin/phpBB/viewtopic.php?t=7131

That one end up not being a bug, but I'm getting bit by a similar problem with HMS SetFolderVariable and %AckComment%. This time however I'm unable to determine a viable workaround. So I'm going to loosely call it a bug but will admit it's probably best called a "feature request".

NOTE: I've tried both with and without the hostmon.ini parameter of:
[Logging]
KeepAckCommentNDays=1

There was no significant change in result.

Below is a very verbose description of the testing and steps to reproduce the "problem".

I'm having trouble saving acknowledgements into a Folder Variable (fvar) using HMS due to the source having spaces and/or multiple lines (CR/LF).

The reason I'm tying to capture this data is part of a bigger project but to keep this topic shorter I've built a sample test for just this piece that I cannot get to work.

The setup is as follows:

Take any test and make it go Warning or Bad so you have the ability to acknowledge it. Then set it with an Action Profile that runs an HMS using Advanced Mode %AcknowledgedJustNow%

#HMS Example 1 (This one was just to check my Syntax)
ResolveMacros Yes <-- I know this is already the default but I forced it anyway.
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment WORD1 WORD2 WORD3 -inheritpartly


RESULT: %fvar_ackcomment% = WORD1

#HMS Example 2 (This one was just to check my Syntax)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment 'WORD1 WORD2 WORD3' -inheritpartly


RESULT: %fvar_ackcomment% = WORD1 WORD2 WORD3

#HMS Example 3 (This one was just to check my Syntax)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment "WORD1 WORD2 WORD3" -inheritpartly


RESULT: %fvar_ackcomment% = WORD1 WORD2 WORD3

#HMS Example 4 (This one is what I'm trying to do but fails due to lack of proper single or double quotes)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment %AckComment% -inheritpartly


RESULT: Only the characters up to the first space are included

#HMS Example 5 (This one fails as shown in the system log)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment '%AckComment%' -inheritpartly

RESULT: %fvar_ackcomment% = blank
RESULT:
[09.30.2023 22:48:07] Sys Error: Unterminated string, ' missing (line # 3:1, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command -ClearedAt (line # 3:2, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:3, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:4, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:5, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:6, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:7, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:8, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command -ClearedAt (line # 3:9, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:10, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:11, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:12, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:13, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:14, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:15, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:16, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:48:07] Sys Error: Wrong command [testuser] (line # 3:17, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)


#HMS Example 6 (This one fails as shown in the system log)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment "%AckComment%" -inheritpartly


RESULT: %fvar_ackcomment% = blank
RESULT:
[09.30.2023 22:50:11] Sys Error: Unterminated string, " missing (line # 3:1, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:2, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command -ClearedAt (line # 3:3, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:4, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:5, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:6, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:7, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:8, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:9, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command -ClearedAt (line # 3:10, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:11, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:12, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:13, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:14, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:15, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:16, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:17, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)
[09.30.2023 22:50:11] Sys Error: Wrong command [testuser] (line # 3:18, script: d:\shares\HM_Scripts\set_fvar_ackcomment.hms)


#HMS Example 4 (This time I entered a quoted string in the ACK comment screen)
ResolveMacros Yes
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment %AckComment% -inheritpartly


I entered the Acknowledgment string with quotes "WORD1 WORD2 WORD3"

RESULT: Those quotes are passed to the HMS and the entire string ends up in the folder variable.

I realize %AckComment% could contain multi-line text if operators append acknowledgements to an already ack'd text (or if we have KeepAckCommentNDays=1 set). And I realize the fvar can only contain one line.

Therefore I think we need a way for applicable commands in HMS (e.g. SetFolderVariable and others) to account for this by either capturing just the first line of any multi-line variable or stripping out the CR/LF, and of course handing the quotes for strings with spaces. Perhaps a new HMS command that lets us select the treatment of multi-line variables. This way we don't break the current logic but we get to choose how we want each script to handle these scenarios. Kind of like how ResolveMacros changes script behavior.

Thoughts, or am I completely missing the basics?
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Mon Oct 02, 2023 3:09 am    Post subject: Reply with quote

Yes, you need to use quotation marks for values with spaces.
Yes, this will not help if value is multi-line string.
Not a bug, always handled this way and should be handled this way.

"Wish list" forum should be used when you need new options or modifications

Yes, I think we can add variables like %AckCommentLine1% .. %AckCommentLine90% and may be %AckCommentLineLast%.
May I ask why do you need to set this as folder-level variable?

Note: as I see your support term expired long time ago. Free updates covered by LifeTime Updates option. You may contact sales @ ks-soft.net regarding support extension

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
seelye



Joined: 17 Sep 2005
Posts: 40
Location: USA

PostPosted: Tue Oct 03, 2023 7:53 am    Post subject: Reply with quote

The reason I partially claimed 'bug' is because of inconsistency in how multi-line variable are handled when being assigned to UDV and FVAR.

If I use the following HMS

SetUserVariable udv_ackcomment %AckComment%
SaveUserVariables
SetCurrentFolder %FullPath%
SetFolderVariable fvar_ackcomment %AckComment% -inheritpartly

Then when I ACK a test with the following text:
Line1 - Word1 Word2 Word3
Line2 - Word1 Word2 Word3

The results are:

%udv_ackcomment% = Line1 - Word1 Word2 Word3

%fvar_ackcomment% = Line1

I'm curious why FVAR doesn't handle this the same as UDV.

As for why we are doing this? Basically we've need a way to capture temporary data from tests for future actions. We are using FVAR somewhat like a register to keep data longer than the test status or test cycle. It allows us to build some complex logic in our Tune-up Reply, Optional status processing, and Action Profiles. Ideally we'd rather use test specific variables (storage registers), but that is definitely a "wish list" and we've not reached the point yet we where really need it. We always try to use what is included before unnecessarily asking you to write more code. We tried using CommentLineNN but it wasn't really working well since we couldn't insure we wouldn't overwrite valid test comments. FVAR so far will work for us.

Support term? I'll get with sales to discuss. This appear a "new" pricing structure; at least for us.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Tue Oct 03, 2023 9:30 am    Post subject: Reply with quote

Quote:
I'm curious why FVAR doesn't handle this the same as UDV.

Some commands may work with such strings without quotation marks because its possible to process in such way single (or last) parameter of the command. In other words - you made mistake but we want to make your life easier and allow HostMonitor to fix missed quotation marks for you (when possible).
For consistency its always safe to use quotation marks.

Quote:
Support term? I'll get with sales to discuss. This appear a "new" pricing structure; at least for us.

For you terms are the same - you still can get updates at no cost.
(support.. we often help clients even with expired support term but this does not mean help is free forever)

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Bug reports All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index