Page 1 of 1 1
Topic Options
#59943 - 2001-10-18 10:24 PM Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Is there any known way to trap a syntax error and not bailout of Kix32? I have a framework where various admin types and even users can customize their environments by creating their own Kix scripts. My corporate script has hooks that use the "call" statement to invoke these additionalscripts if they exist. At times these scripts contain syntax errors that cause the whole scripting session to abend.

I would like to trap syntax errors resulting from a "called" script so that I can log the error and then complete my parent script.

Any thoughts? Should this be suggested to Ruud?

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59944 - 2001-10-18 10:43 PM Re: Trapping a syntax error??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Don't know of a way to trap errors and recover. Just a thought... You may consider RUNning another instance of KiX instead of CALLing it. In your main script, you'd have to watch for the other script to end before proceeding.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59945 - 2001-10-18 11:25 PM Re: Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Already considered that. The down side is that the new script loses all the global variables and previously defined functions. This in my estimation is less desirable than having the user crash himself.

[ 18 October 2001: Message edited by: Howard Bullock ]

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59946 - 2001-10-18 11:49 PM Re: Trapping a syntax error??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yeah, thought it may not be so simple... problem with working in a vaccuum...

I imagine you've thought of leaving their script to the very last so as to affect only them.

Maybe you could get MCA to write a callable KiXChecker to validate their script before you call it. Kludgy, I know, and you'd need to have some sort of revision tracking to avoid rechecking code that hadn't changed from the last time. Come to think of it, maybe Ruud could build that into KiX... something like a /Verify switch...

I'm starting to ramble... sort of cerebral diarrhea...

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59947 - 2001-10-19 12:01 AM Re: Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Currently the script is architected to execute the corporate stuff first then proceed in descending order of scope when calling the scripts ending up at the user. I just want to make a more bullet proof logon application. When the script bombs the logging stops. Since I currently log the calling of and returning from each script I know what script failed, but it just would be nicer to log that fact and continue.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59948 - 2001-10-19 06:41 AM Re: Trapping a syntax error??
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

It is the first time we read something about "users make their own scripts".
Indeed kix32 doesn't have an error recovery mechanism, but with our
tool kixstrip you can pre-process it and you can verify the kixtart
code.
At the moment kixstrip doesn't return an errorlevel, when it encoun-
ters an error situation. We put something on our TO-DO list with a high priority.

A way of running your script without an abortion created by another script
can be by using the run or shell command.
A possible structure:

code:

;
; -first part of your script-
;
IF (Exist("c:\user.kix") = 1)
SHELL '%comspec% /c kix32 c:\user.kix'
ENDIF
;
; -next part of your script-
;

By using kixstrip we are also using find command and GetFileSize function:

code:

;
; -first part of your script-
;
IF (Exist("c:\user.kix") = 1)
; - kixstrip is located somewhere on the server f.e. netlogon directory -
SHELL '%comspec% /c kixstrip c:\user.kix nul >%temp%\zzzzz1.tmp'
SHELL '%comspec% /c find /n /i "no errors found" %temp%\zzzzz1.tmp >%temp%\zzzzz2.tmp'
IF (GetFileSize("%temp%\zzzzz2.tmp") < 30) THEN
CALL "c:\user.kix"
ELSE
? "Warning KIX: script of user contains errors."
ENDIF
del "%temp%\zzzzz?.tmp"
ENDIF
;
; -next part of your script-
;


In a good situation the output of find command can be
code:

---------- c:\users.kix
[11] Informative KIXSTRIP: no errors found.



Greetings.

btw: check the differences between file sizes with and without errors in your situation.
btw: kixstrip can only handle 8.3 filename.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#59949 - 2001-10-19 04:14 PM Re: Trapping a syntax error??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
MCA,
Good idea to use FIND to scrutinize results. My suggestion of RUNning a separate instance was already shot down.

Howard,
If you wanted to setup an INI file, logging users' script revision level, you could do a quick compare between the INI and reality. If they don't match, run the script through MCA's util. If you don't want the overhead in your logon, maybe you could have and admin script that watches for changes.
Still better would be if Ruud could make KiX pre-parse the script or do error recovery.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59950 - 2001-10-19 05:05 PM Re: Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Who has Ruud's ear? I think that this is best resolved by parsing through or performing a pre-compile activity. The command IMHO should validate the syntax and if valid then continue with executuion. If the syntax is not valid, then execution should not happen and the "CALL" command should set @ERROR and @SERROR with the malformed line. This is still Beta. A "SUPERCALL" command could be added with minimal problems and would preserve backward compatibility and the testing that people have done to date.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59951 - 2001-10-19 05:41 PM Re: Trapping a syntax error??
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
A pre-parse would have limited usefulnes. It is all to easy to write a script which will pass a parse ok, but fail when run. Dynamic scripts using execute and accessing array elements that don't exist are a couple of easy ways. Here is a simple example:
code:
dim $aArray[5]

For $iI = 1 to 6
$iI $aArray[$iI] ?
Next


There is nothing intrinsically wrong with the code, but the out of bounds reference will cause a fatal error.

Being able to register a function which is called on a fatal error would be useful, with the reason for the failure passed as a paramater, or available through the @SERROR macro. The return value from the function could be used as a continue point in the script, so you could do something like:

code:
Break ON CLS

; Set fatal error handler
$sRestartPoint=""
if OnFatalCall("udfMyErrorFunction")
"Cannot register OnFatalCall function" ?
Exit 1
EndIf
...
...Corporate script section...
...
...
...
...
$RestartPoint="PostUserScript"
$sUserScript="H:\Logon.kix"
If Exist($sUserScript)
CALL $sUserScript
EndIf

; Restart here if user script fails.
:PostUserScript
$RestartPoint=""
...
... More corporate script ...
...
...
...

Function udfMyErrorFunction($sReason)
$=LogEvent(1,0,"Logon Script Failed due to: " + $sReason,@LSERVER)
$udfMyErrorFunction=$sRestartPoint
EndFunction


<edit>
A null restart point would cause an abort as happens now.
</edit>

[ 19 October 2001: Message edited by: Richard Howarth ]

Top
#59952 - 2001-10-19 05:43 PM Re: Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Exactly! Well said.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59953 - 2001-10-19 08:32 PM Re: Trapping a syntax error??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Poor choice of words "pre-parse the script OR do error recovery" on my part. Should have said "pre-parse the script AND do error recovery". I understand the limitations, but since KiX is interpreted, imagine it would be a tall order for anything more. Error recovery however, should be attainable. Perhaps you should post to Suggestions. Not a fast-track to Ruud's ear, but he does monitor that forum.

Maybe some ONERROR functionality to go with it.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59954 - 2001-10-19 08:58 PM Re: Trapping a syntax error??
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Les,

You beat me to it ... we've already suggested an ON ERROR statement to Ruud and I know for a fact he's seen it - so the bug is (was) in his ear ... but all this talk of pre-parsing, etc makes me a little nervous ... seems a bit overkill no ?

A statement like this should cover this off:

ON ERROR statement

eg:

ON ERROR GOTO "ABORT"
ON ERROR GOSUB "ABORT"
ON ERROR ABORT()

To keep on going :

ON ERROR RESUME

To toggle this feature on/off:

ON ERROR 0 ; it's off
ON ERROR GOTO ABORT ; it's back on

You get the picture, basically a re-hash of the VB documentation ... the power of this approach comes from the fact that statement can be any old statement you want ... so this could work in Howards' situation and probably just about any other ...

Another idea (off-topic) was to build a feature that trapped a user hitting (^C) or killing a (logon) script ... something like this:

ON BREAK statement


This would be very handy (I think) ... would allow one to properly trap (and cleanup) one's script prior to exiting .. maybe even allow one to cancel the pending abort ...

-Shawn

Top
#59955 - 2001-10-20 05:36 AM Re: Trapping a syntax error??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn,
Look at your member number.
Now look at mine.

I'm a relative newbie here, so forgive me if I suggest something that's already been suggested. If you count suggestions like votes, the more the merrier.

I don't see a quick pre-parser as unatainable but full error checking I think is. Error recovery is another matter. I fully ageree with you there bud.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59956 - 2001-10-20 09:14 AM Re: Trapping a syntax error??
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We specially use a RUN '%comspec% /c kix32 user_script.kix'
to prevent users to influence the main script, but to prevent also
you - as network administrator - influence their script.
some possible problems:
- multiple usage of variable names
- open files
- script of user abort kix32.exe by his script
- unexpected changes take place by the client

Questions:

  • what kind of things are your users doing with kixtart?
    - modifying registry keys?
    - removing policies?
    - changing printers?
    - changing desktop + startmenu settings?
    - .....
  • how does you check users aren't use illegal activities with kixtart?
  • what was the reason for this policy within your organisation? so we mention earlier: it is
    the first time users may and can do this kind of things.
    something what we can accept is that an user enter some information and an additional
    program will create automatically a piece of kixtart code which will run by your
    main script.
  • what kind of problems you discover by users scripts?

Greetings.

btw: Shawn good points.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#59957 - 2001-10-21 04:09 AM Re: Trapping a syntax error??
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
We want to provide an environment where we have a common methodology and design to the corporate logon script. I have put a corporate kixtart script framework in place. The corporate logon script performs all the corporate stuff first. Then executes any number of scripts based on the OU hierarchy of both the user account in the global account domain and the computer account in the country resource domain. All of those are owned and operated by the regional, country, or local IT staffs as delegated by the OU structure. When writing those scripts they do have to understand the environment within they are writing their script.

I have a set of published Global variables that they can use without gathering additional data. There is also a corporately control function library that provide things such as: 'MapDrive' and 'WriteLog'. These functions provide error checking, display data(if nec.), and logging. By using these functions all the scripts flow as one with the same look and feel that saves time and code.

If they happen to re-assign a value to a global variable they only screw themselve or those downstream from them for which they are responsible.

The user based scripts come last after all the corporate, regional, country, business unit, etc. stuff has already taken place.

These scripts involve a special user-based Citrix script that the user can configure his Citrix session as he sees fit. Since we have Citrix users from all over the globe hitting the same server farm, we can not always know what his local drive mapping may be. If the user asks, he can get assistance setting this up.

The user.kix that is stored in the user's home share executes last following the user where ever he goes and logs on. This is primarily used by the local LAN support and Help Desk staffs. They establish extra mappings to the software patches and drivers directories.

Most of the computer are locked down so that the user can not hurt himself. For those that have the ability and do hurt themselves, LAN support charges the user's department time & materials and simply kicks off a computer rebuild. Two hours later, everthing is back to normal. The user assumes the risk.

We provide the flexibility and to date it has worked quite well. I just want to improve it some more.

[ 21 October 2001: Message edited by: Howard Bullock ]

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#59958 - 2001-10-21 06:29 AM Re: Trapping a syntax error??
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Thanks for your feedback Howard.
Greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.068 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org