Page 1 of 1 1
Topic Options
#75277 - 2003-06-04 10:18 AM KiX32 won't close down
Peredur ab Efrog Offline
Fresh Scripter

Registered: 2002-06-17
Posts: 6
Loc: Cymru
I have a (lengthy) script which is going to be part of an even larger one. Its purpose is to download and install patches as they become available, when the user starts the system. They are installed by running pkunzip from within a KiX SHELL command.

It all works fine except that if patches are installed (i.e. the SHELL command is executed), the script will not exit.

Here's the script (Note that the MessageBox call immediately before the EndFunction is executed, but the following quit is not. The script exits normally (even without the quit) if the SHELL command is not executed):

;;;;;;;;;;;;;;;;;; Script ;;;;;;;;;;;;;;;;;;;;;

; Globals

$patchDirPath = "\\cimisweb\cimis\common\deployment\patches\8203\"
$usysDir = "c:\usys82\"
$patchLogFileName = "patchlog.txt"

InstallPatches()

Function InstallPatches
Dim $WinVer
Dim $patchLogFile
Dim $empty

$InstallPatches = 0

; Is Uniface 8.2 installed?

if not exist ( $usysDir )
MessageBox( "Error: Missing Usys82 Directory", "Patches", 16 )
quit -1
endif

; Does the patch directory path exist?

if not exist ( $patchDirPath )
MessageBox( "Error: Missing Patch Directory Path", "Patches", 16 )
quit -1
endif

; Store the Windows Version

$WinVer = @ProductType

; Find the patch directory (don't need 95 or NT)

$patchDir = TestAndSetPatchDir( $WinVer, "98" )
if $patchDir = ""
$patchDir = TestAndSetPatchDir( $WinVer, "2000" )
if $patchDir = ""
$patchDir = TestAndSetPatchDir( $WinVer, "XP" )
if $patchDir = ""
MessageBox("Error: Unsupported Operating System", "CIMIS 2000 - Patches", 16)
quit -1
endif
endif
endif

;MessageBox( "Windows Version is: " + $WinVer, "Patches", 64)
;MessageBox( "Patch directory is: " + $patchDir, "Patches", 64)

if not exist ( $patchDir )
MessageBox( "Error: Patch Directory does not exist", "Patches", 16 )
quit -1
endif

$patchLogFile = $usysDir + $patchLogFileName

;MessageBox( "Patch Log File is: " + $patchLogFile, "Patches", 64 )

$empty = 1
$patch = Dir( $patchDir )

While $patch = "." or $patch = ".."
$patch = Dir()
Loop

;$count = 0
While $patch <> "" and @ERROR = 0
;$count = $count + 1
;MessageBox("Loop iteration no: " + $count, "Patches", 64)

if $empty = 1
$empty = 0
endif

; Create the patches log file if it doesn't exist, and open it for reading

if open( 4, $patchLogFile, 3 ) = 0

; read a line from the patch log file

$lineFromPatchLogFile = ReadLine( 4 )

while $patch <> $lineFromPatchLogFile and @ERROR = 0
$lineFromPatchLogFile = ReadLine( 4 )
loop

$saveError = @ERROR
endif

close ( 4 )

;MessageBox("saveError is: " + $saveError + @CRLF + "patch is: " + $patch + @CRLF + "lineFromPatchLogFile is: " + $linefrompatchfile, "Patches", 64)

if $saveError = -1 or $patch <> $lineFromPatchLogfile
MessageBox( "Installing patch: " + $patch, "CIMIS2000 - Patches", 64 )

; do pkunzip stuff
$cmd = "m:\common\deployment\pkunzip.exe -d " + $patchDir + $patch + " " + $usysDir + " -o"
shell $cmd

; open patch log file for writing (error if doesn't exist)

if open( 4, $patchLogFile, 4 ) = 0

; append patch file name to patch log file (+CRLF)

WriteLine( 4, $patch + @CRLF )

; close patch log file

close( 4 )
else
MessageBox( "Error: Couldn't open patch log file!", "CIMIS 2000 - Patches", 16 )
quit -1
endif
endif

$patch = Dir() ; retrieve next file
;MessageBox("Error code is: " + @ERROR + @CRLF + "Next patch is: " + $patch, "Patches", 64)
Loop

MessageBox("Left loop", "Patches", 64)

if $empty = 1 ; patch directory is empty

MessageBox("Patch file empty. Nothing to do", "Patches", 64)

; delete the patch log file
if exist ( $patchLogFile )
del $patchLogFile
endif
endif

MessageBox("Leaving Function", "Patches", 64)
quit 0
EndFunction

Function TestAndSetPatchDir( $windowsVersion, $pattern )
$TestAndSetPatchDir = ""
$startIndex = INSTR ($windowsVersion, $pattern )
if $startIndex > 0
$TestAndSetPatchDir = $patchDirPath + "W" + $pattern + "\"
Endif
EndFunction

Top
#75278 - 2003-06-05 12:57 AM Re: KiX32 won't close down
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
pereduR, my quess is that this line:
code:
$cmd = "m:\common\deployment\pkunzip.exe -d " + $patchDir + $patch + " " + $usysDir + " -o"

might cause some trouble.
try changing it to:
code:
$cmd = "%comspec% /c m:\common\deployment\pkunzip.exe -d " + $patchDir + $patch + " " + $usysDir + " -o"

if it still does not work, add some checks after the line to make sure it really finishes.
this is not first similar post lately, so can't be sure what it is.

also, what is the kix-version used?
_________________________
!

download KiXnet

Top
#75279 - 2003-06-04 01:17 PM Re: KiX32 won't close down
Peredur ab Efrog Offline
Fresh Scripter

Registered: 2002-06-17
Posts: 6
Loc: Cymru
Thanks for the suggestion.

Actually, I am sure it finishes. It executes code following the shell command - even outside of the loop in which the shell command is called.

It works fine with WinZip, but I only have an evaluation copy.

Anyway, I'll try your suggestion (after lunch) and let you know if it works. Thanks again.

Peter

Top
#75280 - 2003-06-04 02:05 PM Re: KiX32 won't close down
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Wow..

Somebody from Wales..

Anyway, IIRC, http://powerarchiver.com has a command-line version of a Zip tool too. However, it is no longer "Freeware."

Not sure if any of these support command-line arguments, but here are several Freeware Zip programs:

http://woundedmoon.org/win32/powerarc611.html

http://www.filzip.com/

http://www.zipgenius.it/

http://www.7-zip.org/

However, as you pointed out there is a command-line version of WinZip available. We have used this successfully for a while now to transfer a large database on a nightly basis.

For example -

Command-line Download - requires WinZip 8.0 (or later)

Command-line Download - requires WinZip 9.0 Beta

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75281 - 2003-06-04 10:04 PM Re: KiX32 won't close down
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I don't think changing the proggy removes the problem.
it's just going around it.

pkunzip is the ultimate solution if speaking of zip in windows world.
_________________________
!

download KiXnet

Top
#75282 - 2003-06-04 10:19 PM Re: KiX32 won't close down
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I don't think that is the point. He is looking to use a command-line zipper. If it not "registered" to him, he has one of two options - find a free one or register (purchase) one.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75283 - 2003-06-04 11:00 PM Re: KiX32 won't close down
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes.
but he said that it works with winzip.
I don't use winzip anymore after found winrar.

anyway, that is not the point.
the point is that it does not work with pkunzip.

which he didn't say that is unregistered. doh.
_________________________
!

download KiXnet

Top
#75284 - 2003-06-04 11:03 PM Re: KiX32 won't close down
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Hmm..

quote:

It works fine with WinZip, but I only have an evaluation copy.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75285 - 2003-06-05 12:10 AM Re: KiX32 won't close down
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, like said before.
the problem is not that it works with some programs.
the problem is that it does not with some others.

that is the question we need to answer...
we don't need to find a freeware product to replace winzip but we need to find out the reason why it does not work for pkunzip.
_________________________
!

download KiXnet

Top
#75286 - 2003-06-05 03:46 PM Re: KiX32 won't close down
Peredur ab Efrog Offline
Fresh Scripter

Registered: 2002-06-17
Posts: 6
Loc: Cymru
Guys,

You've all been really helpful.

The %COMSPEC% suggestion didn't work, I'm afraid. However, since these are actually self-extracting archives, we managed to get around the problem by calling them directly and then using AutoIt to type in the proper directory for extraction, and to close the various windows by sending a series of carriage return characters. AutoIt can produce an executable that can be called from the KiX script, passing in any required parameters (the file name in this case).

Thanks again (Ac ydw. 'Dwi o Gymru. Ond ddim yn wreiddiol. Mae cliw yn yr enw ynglyn a ble ces i fy ngeni!)

Peter (Peredur ab Efrog)

Top
#75287 - 2003-06-05 04:33 PM Re: KiX32 won't close down
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Need to create an executable for KiXtart? Look into KiXCrypt..

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

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 1160 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.023 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