Page 1 of 1 1
Topic Options
#49928 - 2000-05-19 09:41 PM scripting help for updating programs
Anonymous
Unregistered


We have to do regular updates to 2 programs that we are using that are version controlled. The problems we are running into is that the program's automatic updater is completely unreliable and won't work with the ad-hoc updates (the 2nd program) they put out which our users require. The second problem is the userbase sometimes doesn't bother to run the updates themselves and then they come calling. Getting tired of that

The end result is when an update or an Ad Hoc update comes out, I edit the strings in the vars in the kixtart script and when the users log in, they get greeted with the updater program only if they need the update or the ad-hoc update...I'm running Kixtart 3.62.

The 1st attempt at this was to set some Vars in a batch file and some dummy .txt files for the version control (if the .txt is current then skip update kinda thing) then run both the updates, if needed, and from this batch file that the Kixtart script called. That worked perfectly from NT. The problem was that under 9x, only the 1st program would execute, and the would completely forget about the second one. I also tried breaking the main update and ad-hoc updates into their own separate batch files and putting in a Sleep 60 line in between each batch file that Kixstart called and it would pick it up, but if the 1st program takes longer than 60 seconds to update (it varies between 10-60 seconds depending upon the machine/network traffic, etc) it still skips #2, or if it would finish in 10 seconds and the user sits there and waits which I know I'd get complaints about. I thought a Shell call would suspend the script until the program it calls ends?....
So, I tried to programmatically do it and skip the batch files altogether. Again, I can get NT to work, but now 9x doesn't do anything aside from setting the vars (via a shell call to WINSET which the 9x users have in their Windows Dirs)

I'll be the 1st to admit I'm not programmatically inclined so if someone could take a look at this and tell me what I am doing wrong or if there's a better way to do this I'd appreciate it.....

---portion of script for Update and AdHoc---

IF @INWIN="1"
SET "CURRENTVER=5001.txt"
SET "OLDVER=5000.txt"
SET "CURRENTUPDT=UPDT5001.exe"
IF EXIST (%WINDIR% + "\%CURRENTVER%")
GOTO "SKIP1"
ENDIF
DEL "%WINDIR%\%OLDVER%"
COPY "S:\UPDT\%CURRENTVER%" "%WINDIR%"
SHELL "S:\UPDT\%CURRENTUPDT%"
:SKIP1
SET "CURRENTAHVER=AH101b.txt"
SET "OLDAHVER=AH100n.txt"
SET "CURRENTAHUPDT=AH101b.exe"
IF EXIST (%WINDIR% + "\%CURRENTAHVER%")
GOTO "SKIP2"
ENDIF
DEL "%WINDIR%\%OLDAHVER%"
COPY "S:\UPDT\%CURRENTAHVER%" "%WINDIR%"
SHELL "S:\UPDT\%CURRENTAHUPDT%"
:SKIP2

ENDIF
IF @INWIN="2"
SHELL "%windir%\Winset CURRENTVER=5001.txt"
SHELL "%windir%\Winset OLDVER=5000.txt"
SHELL "%windir%\Winset CURRENTUPDT=UPDT5001.exe"

IF EXIST (%WINDIR% + "\%CURRENTVER%")
GOTO "SKIP3"
ENDIF
DEL "%WINDIR%\%OLDVER%"
COPY "S:\UPDT\%CURRENTVER%" "%WINDIR%"
SHELL "S:\UPDT\%CURRENTUPDT%"
:SKIP3
SHELL "%windir%\Winset CURRENTAHVER=AH101b.txt"
SHELL "%windir%\Winset OLDAHVER=AH100n.txt"
SHELL "%windir%\Winset CURRENTAHUPDT=AH101b.exe"
IF EXIST (%WINDIR% + "\%CURRENTAHVER%")
GOTO "SKIP4"
ENDIF
DEL "%WINDIR%\%OLDAHVER%"
COPY "S:\UPDT\%CURRENTAHVER%" "%WINDIR%"
SHELL "S:\UPDT\%CURRENTAHUPDT%"
:SKIP4

ENDIF

---End of portion---

Sorry for dumping a ton of code out, but I'm baffled. I switched the program order around and it will still only call the 1st program....it kind of looks like the login script just continues onto the end without stopping for the second program...Any ideas?

Thanks,

Mike Weitsen

[This message has been edited by mweitsen (edited 19 May 2000).]

Top
#49929 - 2000-05-21 09:55 PM Re: scripting help for updating programs
PaulMoxey Offline
Getting the hang of it

Registered: 1999-07-22
Posts: 90
Loc: Villawood, NSW, Australia
At first glance, I'd make a few changes to the way your labels and endif statements are placed...

That coupled with using winset to define variables when you are only using them within kix itself.. Let kix do the hardwork...

code:

IF @INWIN="1" ; IF OS is NT
SET $CURRENTVER="5001.txt"
SET $OLDVER="5000.txt"
SET $CURRENTUPDT="UPDT5001.exe"
IF EXIST (%WINDIR%+$CURRENTVER)
GOTO "SKIP1"
ENDIF
DEL "%WINDIR%\$OLDVER"
COPY "S:\UPDT\$CURRENTVER" "%WINDIR%"
? "Updating to version "+$CURRENTVER+"..."
SHELL "S:\UPDT\"+$CURRENTUPDT

:SKIP1
SET $CURRENTAHVER="AH101b.txt"
SET $OLDAHVER="AH100n.txt"
SET $CURRENTAHUPDT="AH101b.exe"
IF EXIST (%WINDIR%+$CURRENTAHVER)
GOTO "SKIP2"
ENDIF
DEL "%WINDIR%+$OLDAHVER"
COPY "S:\UPDT\"+$CURRENTAHVER" "%WINDIR%"
? "Updating to version "+$CURRENTAHVER+"..."
SHELL "S:\UPDT\"+$CURRENTAHUPDT
endif ; end if OS = NT

:SKIP2
IF @INWIN="2" if OS is 95/98
SET $CURRENTVER="5001.txt"
SET $OLDVER="5000.txt"
SET $CURRENTUPDT="UPDT5001.exe"
IF EXIST (%WINDIR%+$CURRENTVER)
GOTO "SKIP3"
ENDIF
DEL "%WINDIR%\$OLDVER"
COPY "S:\UPDT\$CURRENTVER" "%WINDIR%"
? "Updating to version "+$CURRENTVER+"..."
SHELL "S:\UPDT\$CURRENTUPDT"
goto skip4 ; already currentver

:SKIP3
SET $CURRENTAHVER="AH101b.txt"
SET $OLDAHVER="AH100n.txt"
SET $CURRENTAHUPDT="AH101b.exe"
IF EXIST (%WINDIR%+$CURRENTAHVER)
GOTO "SKIP4"
ENDIF
DEL "%WINDIR%+$OLDAHVER"
COPY "S:\UPDT\$CURRENTAHVER" "%WINDIR%"
? "Updating to version "+$CURRENTAHVER+"..."
SHELL "S:\UPDT\$CURRENTAHUPDT"
endif ; end if OS is 95/98

:SKIP4 ; end of the updating....



------------------
Paul Moxey
POS & Senior Network Administrator
Taubmans Pty Ltd
Paul_Moxey@taubmans.com.au

_________________________
Paul Moxey POS & Senior Network Administrator BarloworldCoatings (AUST) Pty Ltd

Top
#49930 - 2000-05-22 04:27 PM Re: scripting help for updating programs
Anonymous
Unregistered


Paul,

Thanks for your thoughts and code snippet. I tried it, however, now neither NT or 9x work. 9x goes through without any clues, but NT comes up with a BEEP during the login which it didn't before. Is there anywhere I can figure out what/where it blew up?

Mike

Top
#49931 - 2000-05-23 10:27 AM Re: scripting help for updating programs
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
This line is missing a semi-colon but that doesn't explain the beep in NT.

IF @INWIN="2" ; if OS is 95/98


I suggest you run the script from a DOS box plus add a few print statements so you can see when it is bombing & why. My best guess is some file or exe that is required by the script is misnamed.

Paul,

I generally feel real uncomfortable about jumping out of the middle of an if statement without processing the endif. I wonder does kix clean up properly & close everything off OK when you do this? (i.e. GOTO "SKIP2")

[This message has been edited by JackLothian (edited 23 May 2000).]

_________________________
Jack

Top
#49932 - 2000-05-23 11:45 AM Re: scripting help for updating programs
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jack:

I've always wondered that as well. And I avoided using goto's because of it ( interesting side-effect being good structured code ?)

Then I learned a thing or two from developing "scripted" type applications myself ...

With Paul's permission - may I propose a theory on this ...

Scripted IF statements are usually implemented like a stack - with internalized push's and pop's - like this ...

code:

IF EXPRESSION (push)


IF EXPRESSION (push)


IF EXPRESSION (push)


ENDIF (pop)


ENDIF (pop)


ENDIF (pop)


KiX should/would always know how "deeply" IF nested it is at any given time.

When ones does a GOTO inside a deeply nested IF statement, scripting languages usually "POP" the entire stack then continue on like there's no pending (stacked) ENDIF.

I hope this doesn't start the old "GOTO/NOGOTO" debate !

Unless anyone's interested ?

Shawn.

p.s.

I did have a point to all this rant (and not just the one on my head)...

Using GOTO's in deeply nested IF's works. Sometimes it seems like the only way to go !

But I thought Jack, that you would have more to say about whether it was "COOL" or not !

Shawn..

[This message has been edited by Shawn (edited 23 May 2000).]

Top
#49933 - 2000-05-23 01:23 PM Re: scripting help for updating programs
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
We are getting off Mike's topic but it wasn't really the issue of being well structured that bother me since I have been known to use a few GOTOs myself.

Seeing that jump in the middle just started me thinking. Kix is an excellant scripting language but to me it does seem somewhat unsophisticated. I have often wonder how kixtart could possibly track all the push & pulls & keep the book keeping straight when you use a goto. In your example consider:


IF EXPRESSION (push)
IF EXPRESSION (push)
IF EXPRESSION (push)
goto test
ENDIF (pop)
ENDIF (pop)
:test
ENDIF (pop)

When you consider that you could be calling this code scrap with a call statement that is embedded in an IF-ELSEIF-ENDIF statement it gets even worse.

Because I was unsure about how sophisticated kix was in handling these situtations I tended to avoid them.

_________________________
Jack

Top
#49934 - 2000-05-23 02:53 PM Re: scripting help for updating programs
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Jack:

Can you believe it ? This script works !

code:

break on

if 1=1

if 2=2

if 3=3

?"3=3"
goto getout

:getout

if 4=4

?"4=4"

if 5=5

?"5=5"

endif

endif

return


Either KiX is real dumb or unbelievably clever - I haven't figured out which one yet ! (Probably the latter)

Shawn.

Anyway - this does nothing for Mike's problem - sorry guys !

[This message has been edited by Shawn (edited 23 May 2000).]

Top
#49935 - 2000-05-23 03:17 PM Re: scripting help for updating programs
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
My suspicion is kix is very linear & it pops the IF stack as it encounters ENDIFs. Thus when you jump out of an IF structure you leave some hanging. I suspect when the script encounters the end of the routine (STOP or RETURN) it collapses all incomplete IF statements that are localized within that routine. In most instances this should work successfully and give predictable results.

PS. Mike,

If you still have questions feel free to add on to this thread or open a new one.

_________________________
Jack

Top
#49936 - 2000-05-23 05:39 PM Re: scripting help for updating programs
Anonymous
Unregistered


All,

Jack's correct that it will pop after it sees an endif (the manual states that labels cannot be jumped to outside of their endifs)

I rewrote the script to move the label jumps inside, right befor the endifs and now the script doesn't error out, but doesn't do anything either.

Completely at a loss,

Mike


Top
#49937 - 2000-05-23 06:11 PM Re: scripting help for updating programs
Anonymous
Unregistered


Jack,

You mentioned testing this script with some print statements in a DOS window as to get an idea of what's doing who. The manual doesn't mention anything under "PRINT"

what's the syntax for this?

Top
#49938 - 2000-05-24 10:44 AM Re: scripting help for updating programs
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Use the question mark. You must run this from a DOS box though. So logon to a Win95 machine with kix installed locally & execute your script from the dos box. Scatter a few statements like:

? "I am here"

& print a few key variables like this:

? $Var

You get the idea.

_________________________
Jack

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 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.111 seconds in which 0.031 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