#24968 - 2002-07-12 01:32 PM
Re: Problems with script - Gosub command
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Every "IF" needs and "Endif". As you vcan see your code is malformed. code:
IF INGROUP ("MOVED_USERS") GOSUB gla ELSE IF INGROUP ("GRAMPIAN-GRP") GOSUB gra ELSE IF INGROUP ("PANDD-GRP") GOSUB pan ELSE IF INGROUP ("PRIME-GRP") GOSUB pri ENDIF
I would suggest simplifing your code by using the "select..endselect" construct. code:
select case INGROUP ("MOVED_USERS") GOSUB "gla" case INGROUP ("GRAMPIAN-GRP") GOSUB "gra" case INGROUP ("PANDD-GRP") GOSUB "pan" case INGROUP ("PRIME-GRP") GOSUB "pri" endselect
[ 12 July 2002, 13:33: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#24971 - 2002-07-12 03:08 PM
Re: Problems with script - Gosub command
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Why are you duplicating your code and running basically the same code for NT and Win95? Much of your code is exactly the same. [ 12 July 2002, 15:08: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#24973 - 2002-07-12 03:14 PM
Re: Problems with script - Gosub command
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear Cazzhj,
We advise you:
use the original script for modifications and use "kixstrip /debug" output only for debugging.
kixstrip doesn't have the capability to remove unwanted debugging elements from your script. also you make it impossible for kixstrip - to layout your script. - to find the right missing quotations. debugging elements contain also quotations.
Kixstrip returns for your version as screen output
code:
Kixstrip 4.10 (vs 3.18e) (c) MCA - scripting@wanadoo.nl - 2000, 2001, 2002 . 1 .........................E(492) . Warning KIXSTRIP: 364 line incomplete "single quotation". Warning KIXSTRIP: 364 line incompleted. . Kixstrip 4.10 (vs 3.18e) 3.13 (sec) . input 492 script.kix output 492 debug.kix (skip: 0 blocks: 0 labels: 16) block_check -ERROR- block_errors=2 block_structures=82 labels=16 tab=6 (default) . Warning KIXSTRIP: 2 errors in block structure(s). missing statement(s). - do:until [0:0] - for|each:in|to:step|next [0|0:0|0:0|0] - function:endfunction [0:0] -ERROR- - if:else:endif [82:8:80] - select:case:endselect [0:0:0] - while:loop [0:0] 82 block_structures found. Informative KIXSTRIP: no UDF's found. Warning KIXSTRIP: 1 line is incompleted. rerun program with option "/block_check /show_errors". Warning KIXSTRIP: some lines contains errors or possible errors. . active options: /Block_Check /Headers /Print /Show_Structure /TAB=6 /Translate inactive options: /NoCombine /NoDebug /NoPerformance /NoProgress /NoShow_Errors /NoLicense: (not.specified)
and you doesn't get any structur in your version.
greetings.
btw: some remarks about the code - GOSUB calls end with a RETURN - don't use ":end" too much times - your code
code:
.... ENDIF USE U: /delete /persistent USE U: "\\QCLUNT01\users" CD U:\users\@userid ENDIF ; -------> Warning KIXSTRIP: 349 block "if/else/endif" incompleted. starting point of block structure missing. ; -------> Warning KIXSTRIP: 349 block incompleted.
was missing an "IF Ingroup" statement or "ENDIF" is too much. please return for Lonkero to the board, what is should be. [ 12 July 2002, 15:16: Message edited by: MCA ]
|
Top
|
|
|
|
#24975 - 2002-07-12 04:04 PM
Re: Problems with script - Gosub command
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You have an extreme duplication of code.
You may want to consider something like the sample for "GLA" below. I have not analyzed the level of duplication between the subroutines GLA, GRA, PAN , and PRI. You should strive to reduce the duplication. Doing so will make maitenance much easier. code:
:GLA ? "USERS NAME IS " + @fullname ? "MACHINE NAME IS " + @wksta ? "IP ADDRESS IS " + @ipaddress0 ? "CPU IS " + @cpu ? "OPERATING SYSTEM IS " + @producttype ? "SERVICE PACK IS " + @csd ? ? "ERRORS ARE " +@error " WHICH MEANS " + @serror ? If @INWIN=1 If InGroup("IT-PRINT1-GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL502") ? "Added printer connection.........." ENDIF
IF InGroup("IT-PRINT2_GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL501") ? "Added printer connection.........." ENDIF If InGroup("checkline-grp") MapDrive("H:","GCKLNT01","wineftnt") Endif IF InGroup("MOVED_USERS") SHELL 'SUBST U: /D ' SHELL 'SUBST U: "\\gfclnt03\users\%username%" ' ENDIF
IF InGroup("RESEARCH-GRP") MapDrive("Z:","GAPPNT02","RESEARCH") MapDrive("P:","GMSHNT01","Public") ENDIF Else ; Win95 IF InGroup("MOVED_USERS") MapDrive("U:","gfclnt03","users") CD U:\users\@userid ENDIF Endif IF InGroup("Scottish Magazines") MapDrive("N:","GAPPNT04","ScottishMagazines") ENDIF
IF InGroup("Solus-Grp") MapDrive("Q:","GAPPNT04","SolusBookingSystem") ENDIF
IF InGroup("ADQUICK-GRP") MapDrive("G:","GTPSNT01","Quick") ENDIF
IF InGroup("CUSTSERV-GRP") MapDrive("R:","GAPPNT02","CSDBase") ENDIF
IF InGroup("SATEAM-GRP") MapDrive("X:","GMSHNT01","TECH_SUPPORT") ENDIF
IF InGroup("MOVE-GRP") MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("CENTRALS-GRP") ; MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("GPNCENTRALS-GRP") ; MapDrive("N:","QCLUNT01","CentralServices") ENDIF
IF InGroup("BROADCAS-GRP") MapDrive("K:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("BROADDIST-GRP") MapDrive("I:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("GPNBROADCAST-GRP") MapDrive("O:","QCLUNT01","Broadcasting") ENDIF
IF InGroup("PUBLISHI-GRP") MapDrive("L:","GFCLNT04","Publishing") ENDIF
IF InGroup("S1-GROUP") MapDrive("V:","GAPPNT03","S1") USE V: "\\GAPPNT03\S1" ENDIF
IF InGroup("COGNOS-USERS") MapDrive("Y:","GTPSNT01","cognos") ENDIF
IF InGroup("SUNDAY-GRP") MapDrive("S:","GMSHNT01","Sunday") ENDIF
IF InGroup("STE-GRP") MapDrive("M:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("MARKETIN-GRP") MapDrive("T:","GAPPNT05","Despatch_DB") ENDIF
IF InGroup("MARKETDB-GRP") MapDrive("S:","GAPPNT05","NSDOCS") ENDIF
IF InGroup("MAGASUBS-GRP") MapDrive("F:","GAPPNT02","MAGAZINES") ENDIF
IF InGroup("GPNPUBLIC-GRP") ; MapDrive("Q:","QCLUNT01","Public") MapDrive("P:","GMSHNT01","Public") ENDIF RETURN
;-------------------------------------------------------------------------------------------------- Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share Color c+/n If $Drive<>"" and $Server<>"" and $Share<>"" $LogText="Connecting $Drive to \\$Server\$Share" ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\$Server\$Share" If @error=0 color g+/n $x=" - Success" "$x" Else color r+/n $x=" - Failed: Error @error" "$x" $ErrorState=1 Endif WriteLog ($LogText + $x) Color w+/n Else WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction ;-------------------------------------------------------------------------------------------------- Function WriteLog($text) dim $RC, $text, $LogFile, $Filehandle $Filehandle = 1 $LogFile = "%temp%\logon.log" $RC=Writeline ($Filehandle, "@Date @Time - $Text" + Chr(13) + Chr(10)) if $RC<0 $RC=Close ($Filehandle) $RC=Open ($Filehandle, $LogFile, 5) Select Case $RC=-1 $RC=MessageBox ("Invalid file name ($LogFile) specified for log file.","Logon Script Error",48) Case $RC=0 WriteLog ($Text) Case $RC=>0 $RC=MessageBox ("Error($RC) while attempting to open log file ($LogFile).","Logon Script Error",48) Endselect Endif EndFunction
|
Top
|
|
|
|
#24976 - 2002-07-13 02:17 AM
Re: Problems with script - Gosub command
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear Howard,
A good reduction of it. greetings.
|
Top
|
|
|
|
#24977 - 2002-07-16 05:38 PM
Re: Problems with script - Gosub command
|
Cazzjh
Fresh Scripter
Registered: 2002-06-04
Posts: 32
Loc: Glasgow, Scotland
|
Thanks for that Howard - have modified it to be like :
code:
SELECT CASE INGROUP ("MOVED_USERS") GOSUB gla CASE INGROUP ("GRAMPIAN-GRP") GOSUB gra CASE INGROUP ("PRIME-GRP") GOSUB pri CASE INGROUP ("PANDD-GRP") GOSUB pan CASE 1 ; not in any of the above groups ENDSELECT
:PRI
MapDrive("J:", "LAPPNT02", "AREV31") MapDrive("F:", "LAPPNT02", "PSDATA")
RETURN
:PAN IF @INWIN = 1 SHELL 'SUBST U: /D ' SHELL 'SUBST U: "\\lbdcnt01\%username%" ' MapDrive("J:", "LFILNT01", "PearlAndDean") MapDrive("K:", "LAPPNT01", "ACT")
ELSE ; Win95 MapDrive("U:","lbdcnt01", "Users") CD U:\users\@userid MapDrive("J:", "LFILNT01", "PearlAndDean") MapDrive("K:", "LAPPNT01", "ACT") ENDIF
RETURN
:GLA ? "USERS NAME IS " + @fullname ? "MACHINE NAME IS " + @wksta ? "IP ADDRESS IS " + @ipaddress0 ? "CPU IS " + @cpu ? "OPERATING SYSTEM IS " + @producttype ? "SERVICE PACK IS " + @csd ? ? If @INWIN=1 If InGroup("IT-PRINT1-GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL502") ? "Added printer connection.........." ENDIF
IF InGroup("IT-PRINT2_GRP") $null=AddPrinterConnection("\\Gfclnt04\CITSL4C1") $null=AddPrinterConnection("\\Gfclnt04\CITSLJ03") $null=AddPrinterConnection("\\Gfclnt04\AITSL502") $null=AddPrinterConnection("\\Gfclnt04\AITSL501") $null=SetDefaultPrinter("\\Gfclnt04\AITSL501") ? "Added printer connection.........." ENDIF If InGroup("checkline-grp") MapDrive("H:","GCKLNT01","wineftnt") Endif IF InGroup("MOVED_USERS") SHELL 'SUBST U: /D ' SHELL 'SUBST U: "\\gfclnt03\users\%username%" ' ENDIF
IF InGroup("RESEARCH-GRP") MapDrive("Z:","GAPPNT02","RESEARCH") ENDIF
Else ; Win95
IF InGroup("MOVED_USERS") MapDrive("U:","gfclnt03","users") CD U:\users\@userid ENDIF Endif :GRA IF @INWIN = 1 IF InGroup("LOCAL_ADMINS") SHELL "CMD /C SUBST U: /D" ELSE SHELL 'SUBST U: /D ' SHELL 'SUBST U: "\\QCLUNT01\users\%username%" ' ENDIF
ELSE ; win95
MapDrive("U:", "QCLUNT01", "users") cd U:\users\@USERID ENDIF
IF InGroup("Scottish Magazines") MapDrive("N:","GAPPNT04","ScottishMagazines") ENDIF
IF InGroup("Solus-Grp") MapDrive("Q:","GAPPNT04","SolusBookingSystem") ENDIF
IF InGroup("ADQUICK-GRP") MapDrive("G:","GTPSNT01","Quick") ENDIF
IF InGroup("CUSTSERV-GRP") MapDrive("R:","GAPPNT02","CSDBase") ENDIF
IF InGroup("SATEAM-GRP") MapDrive("X:","GMSHNT01","TECH_SUPPORT") ENDIF
IF InGroup("MOVE-GRP") MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("CENTRALS-GRP") ; MapDrive("J:","GFCLNT04","CentralServices") ENDIF
IF InGroup("GPNCENTRALS-GRP") ; MapDrive("N:","QCLUNT01","CentralServices") ENDIF
IF InGroup("BROADCAS-GRP") MapDrive("K:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("BROADDIST-GRP") MapDrive("I:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("GPNBROADCAST-GRP") MapDrive("O:","QCLUNT01","Broadcasting") ENDIF
IF InGroup("PUBLISHI-GRP") MapDrive("L:","GFCLNT04","Publishing") ENDIF
IF InGroup("S1-GROUP") MapDrive("V:","GAPPNT03","S1") USE V: "\\GAPPNT03\S1" ENDIF
IF InGroup("COGNOS-USERS") MapDrive("Y:","GTPSNT01","cognos") ENDIF
IF InGroup("SUNDAY-GRP") MapDrive("S:","GMSHNT01","Sunday") ENDIF
IF InGroup("STE-GRP") MapDrive("M:","GFCLNT04","Broadcasting") ENDIF
IF InGroup("MARKETIN-GRP") MapDrive("T:","GAPPNT05","Despatch_DB") ENDIF
IF InGroup("MARKETDB-GRP") MapDrive("S:","GAPPNT05","NSDOCS") ENDIF
IF InGroup("MAGASUBS-GRP") MapDrive("F:","GAPPNT02","MAGAZINES") ENDIF
IF InGroup("GPNPUBLIC-GRP") ; MapDrive("Q:","QCLUNT01","Public") ENDIF
MapDrive("P:","GMSHNT01","Public")
RETURN
;-------------------------------------------------------------------------------------------------- Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share Color c+/n If $Drive<>"" and $Server<>"" and $Share<>"" $LogText="Connecting $Drive to \\$Server\$Share" ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\$Server\$Share" If @error=0 color g+/n $x=" - Success" "$x" Else color r+/n $x=" - Failed: Error @error" "$x" $ErrorState=1 Endif WriteLog ($LogText + $x) Color w+/n Else WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction ;-------------------------------------------------------------------------------------------------- Function WriteLog($text) dim $RC, $text, $LogFile, $Filehandle $Filehandle = 1 $LogFile = "\\Gfclnt03\Users\LoginLogs\logon.log" $RC=Writeline ($Filehandle, "@Date @Time - $Text" + Chr(13) + Chr(10)) if $RC<0 $RC=Close ($Filehandle) $RC=Open ($Filehandle, $LogFile, 5) Select Case $RC=-1 $RC=MessageBox ("Invalid file name ($LogFile) specified for log file.","Logon Script Error",48) Case $RC=0 WriteLog ($Text) Case $RC=>0 $RC=MessageBox ("Error($RC) while attempting to open log file ($LogFile).","Logon Script Error",48) Endselect Endif EndFunction
It still will not go to each section correctly. Have ran it through kixstrip and there are no errors. It just doesn't seem to be using the select statement correctly, doesn't matter if I change it to an if statement either - still will not work.
HELP!!!!!
_________________________
Cazzjh
|
Top
|
|
|
|
#24979 - 2002-07-16 09:31 PM
Re: Problems with script - Gosub command
|
Cazzjh
Fresh Scripter
Registered: 2002-06-04
Posts: 32
Loc: Glasgow, Scotland
|
Tried the enumlocalgroup - it returns as being in the correct groups - but it still doesn't work!!
_________________________
Cazzjh
|
Top
|
|
|
|
#24981 - 2002-07-16 09:40 PM
Re: Problems with script - Gosub command
|
Cazzjh
Fresh Scripter
Registered: 2002-06-04
Posts: 32
Loc: Glasgow, Scotland
|
This part :
code:
SELECT CASE INGROUP ("MOVED_USERS") GOSUB gla CASE INGROUP ("GRAMPIAN-GRP") GOSUB gra CASE INGROUP ("PANDD-GRP") GOSUB pan CASE 1 ; not in any of the above groups ENDSELECT
If windows 95, it seems to ignore if a user is a member of each of those groups and exits or in NT, it recognises GLA and GRA but not PRI or PAN, if a user is a member of any of those groups it will map drives for both of them regardless!!
_________________________
Cazzjh
|
Top
|
|
|
|
#24984 - 2002-07-16 09:51 PM
Re: Problems with script - Gosub command
|
Cazzjh
Fresh Scripter
Registered: 2002-06-04
Posts: 32
Loc: Glasgow, Scotland
|
Tried that I am afraid - still does not work - I am getting pretty frustrated now!!
Yeah this service is replicated to all domain comtrollers [ 16 July 2002, 21:52: Message edited by: Cazzjh ]
_________________________
Cazzjh
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 323 anonymous users online.
|
|
|