Page 1 of 2 12>
Topic Options
#118420 - 2004-04-21 10:50 PM ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Using Lonk's version of enumINI() - Load ini-file into array

I can get the drives to map for everything except user's H: drives..

Code:

CLS
BREAK ON
DIM $rc
;$rc=SETOPTION("NoVarsInStrings","ON")
;ENUMINI(@scriptdir+"\DRIVES.INI")
;?
;?'Process complete..'
;get $

"treeview of ini-file"
$data=enumINI(@scriptdir+"\DRVMAP.ini")
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
?'"'+$grp='"'
IF INGROUP($grp)
?"member of "+$grp
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
?$drive+':' $resource
?$drive
?$resource
NEXT
ENDIF
NEXT
ELSE
$grp=$section[0]
?'"'+$grp+'"'
IF INGROUP($grp)
?"member of "+$grp
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
?$drive+':' $resource
?$drive
?$resource
NEXT
ENDIF
ENDIF
NEXT
ENDIF
??"process complete.."
GET $



INI Structure is as follows:
Code:

[DOMAIN1\MMC PDX,DOMAIN2\PDX]
H=\\RESOURCE\@userid$
R=\\APPS\APPS
S=\\RESOURCE\SHARED
[Beaverton]
F=\\REMOTE\apps
H=\\REMOTE\USERS$\+@userid
R=\\APPSERVER\apps
S=\\REMOTE\shared
T=\\RESOURCE\shared
[Marketing]
N=\\IIS\MARKET
[DOMAIN1\Info_Technology,DOMAIN2\MMC Info_Technology]
G=\\RESOURCE\IS



I have tried to use the EXECUTE to do this with no success.

Thanks,

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

Top
#118421 - 2004-04-21 11:02 PM Re: ENUMINI() - Revisited
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well.. I can't see how execute is supposed to work on the line:
\\REMOTE\USERS$\+@userid

there are no quotes for concatenation.
'\\REMOTE\USERS$\'+@userid
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#118422 - 2004-04-21 11:05 PM Re: ENUMINI() - Revisited
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Maybe you could just leave out the +
\\REMOTE\USERS$\@userid
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#118423 - 2004-04-21 11:46 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Went back through my notes and found the answers..

Code:

H=\\RESOURCE\+@userid+'$'
W=\\RESOURCE\USERS+'$\'+@userid



Thanks for your help.

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

Top
#118424 - 2004-04-22 12:50 AM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. If I comment out -
Code:

$rc=execute('$$resource='+$resource)



It works fine, but if I uncomment it, and run with the login script it shows:
Quote:


ERROR : undefined variable []!
Script: \\SERVER\NETLOGON\newscript\ENUMINI.KIX
Line : 1





Thanks,

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

Top
#118425 - 2004-04-22 01:07 AM Re: ENUMINI() - Revisited
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
That would indicate you set 'explicit','on'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#118426 - 2004-04-22 02:56 AM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I take it with this example I cannot use that? I have been using this to clean up our login script quite significantly.

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

Top
#118427 - 2004-04-22 03:58 AM Re: ENUMINI() - Revisited
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You could of course, DIM all the vars.

Your way of using Execute() precludes 'NoVarsInStrings' too.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#118428 - 2004-04-22 02:25 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I have covered that already, but did not post until now as I was trying to get out of the office for a HALO Party last night.

Code:

DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP(''+$grp+'')
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
$grp=$section[0]
IF INGROUP(''+$grp+'')
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
ENDIF



Is there a better or different way to do the EXECUTE(), so that I can get the hidden mappings?

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

Top
#118429 - 2004-04-22 04:34 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. figured part of it out..

Changed -
Code:

$rc=execute('$$resource='+$resource)



To -
Code:

$rc=execute('$resource='+$resource)



However, it does not map the H: drive proper.

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

Top
#118430 - 2004-04-22 05:24 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. Here is the updated script - thanks Les for pointing me in the right direction..

Code:

DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
$rc=SETOPTION('NoVarsInStrings','Off')
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP($grp)
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
IF INGROUP($section[0])
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
$rc=execute('$$resource='+$resource)
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
$rc=SETOPTION('NoVarsInStrings','On')
ENDIF



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

Top
#118431 - 2004-05-07 06:07 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
We seem to be having a problem with groups preceded with an underscore "_".

For example -
Code:

[DOMAINA\_IT Systems Engineering]
N=\\DevServ\groups\Technology Services\Systems Engineering
I=\\APPS\INSTALLS
J=\\MAIN\SHARE+'$$'


It appears to bomb on the "header" for this section of the file.

Thanks,

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

Top
#118432 - 2004-05-08 01:08 AM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. Here is what works.. Now, that we sorted out the "_" deal.

Note: The check for '$$' is really only needed when an Admin share is used and then it is executed.

Code:

; -- PURPOSE: Map user drives from an INI file and into an array
FUNCTION DRVMAP
DIM $rc,$data,$section,$grp,$value,$drive,$resource
$data=enumINI(@LDRIVE+'\NewScript\DRVMAP.ini')
IF @error
? "something went wrong: @serror"
SLEEP 2
ELSE
$rc=SETOPTION('NoVarsInStrings','Off')
FOR EACH $section IN $data
IF INSTR($section[0],',')
FOR EACH $grp IN SPLIT($section[0],',')
IF INGROUP($grp)
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
IF INSTR($resource,'$$')
$rc=execute('$$resource='+$resource)
ENDIF
USE $drive+':' $resource
NEXT
ENDIF
NEXT
ELSE
IF INGROUP($section[0])
FOR $value=1 TO ubound($section)
$drive=$section[$value][0]
$resource=$section[$value][1]
IF INSTR($resource,'$$')
$rc=execute('$$resource='+$resource)
ENDIF
USE $drive+':' $resource
NEXT
ENDIF
ENDIF
NEXT
$rc=SETOPTION('NoVarsInStrings','On')
ENDIF
ENDFUNCTION



Thanks,

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

Top
#118433 - 2004-05-08 01:22 AM Re: ENUMINI() - Revisited
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, so you say having string with macros in it gets executed automatically?
_________________________
!

download KiXnet

Top
#118434 - 2004-05-08 04:16 AM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I think you are right.. It works well now, but I think it can be distilled down more - for a good Golf score.

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

Top
#118435 - 2004-05-08 06:59 PM Re: ENUMINI() - Revisited
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, if your macros and vars work from the input, then executing on the admin share is not needed either.
but here we go...
ruud has made it so, that vars in strings does not include macros.
thus, you should be safe but leaving no vars in strings on.
_________________________
!

download KiXnet

Top
#118436 - 2004-05-09 07:45 AM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I guess we need to re-visit this as the only way to work this is to run the NOVARSINSTRING OFF and then ON again. If left as ON, I get an error on LINE 1 [] as it triess to break up the groups in each header of the INI file.

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

Top
#118437 - 2004-05-09 10:16 AM Re: ENUMINI() - Revisited
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, doesn't that sound a bit buggy
_________________________
!

download KiXnet

Top
#118438 - 2004-05-09 05:19 PM Re: ENUMINI() - Revisited
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
So the question still remains..

Can it be done with NOVARSINSTRINGS ON?
Code:

[DOMAINA\ACCTG,DOMAINB\ACCOUNTING]
G=\\SERVER\ACCTG
S=\\APPSERVER\APPS
[DOMAINA\HR]
G=\\SERVER\HR
S=APPSERVER\SHARED


So, the point being if you have one group or many groups that need to be split up, it does not seem to matter.

Thanks,

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

Top
#118439 - 2004-05-10 02:37 AM Re: ENUMINI() - Revisited
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
There could be some matters arround Execute() and NoVarsInStrings.

Could you try the following function, whitch turns on VarsInStrings before Execute() and then restores it to its previous state.

Code:

Function DRVMAP()
Dim $rc,$data,$section,$grp,$i,$drive,$resource,$NoVarsInStrings
$data = EnumINI(@LDrive + '\NewScript\DRVMAP.ini')
If Not @Error
For Each $section In $data
$grp = Split($section[0],',')
If InGroup($grp)
For $i = 1 To UBound($section)
$drive = $section[$i][0] + ':'
$resource = $section[$i][1]
$NoVarsInStrings = SetOption('NoVarsInStrings','Off')
$rc = Execute('$$resource=$resource')
$rc = SetOption('NoVarsInStrings',$NoVarsInStrings) ; Set NoVarsInStrings to previous state
Use $drive $resource
Next
EndIf
Next
EndIf
EndFunction



-Erik

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

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

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