Page 1 of 1 1
Topic Options
#62421 - 2002-01-26 12:22 AM Mapping variable drive letters from file....
Anonymous
Unregistered


Hi!
Just a bit cryptic subjectline there...
Now I have a problem (again).

Here's the story:
I have 4 folders on a server ("Server01")
The folders are shared with the following names:
Test1
Test2
Test3
Test4

In the "Netlogon" folder I have a file called "folders.txt".
This file contains 4 lines...
Test1
Test2
Test3
Test4

Now, I'm trying to map those folders by using the following testscript, using Bryces MapDrive-function and by reading the lines in folders.txt.

I have tested with some "printlines" and from that I know the script reads the lines in the .txt-file, but I don't get any mapped drives.

Here's the script:

code:

$srvr = @LSERVER
$quota_drive = $srvr + "\"
$q_log_path = $srvr + "\netlogon\Folders.txt"
Function MapDrive($drives,$resource)
DIM $LastDrive,$drive
$drives = split($drives,",")
$lastdrive = $drives[ubound($drives)]
for each $drive in $drives
use $drive: $resource
if @error = 0
$mapdrive = $drive
exit(0)
endif
if $drive = $lastdrive
$mapdrive = "N/A"
exit(1)
endif
next
EndFunction

OPEN(5,$q_log_path,3)
WHILE @ERROR = 0
$X = ReadLine(5)
$Mapped_drv = $quota_drive + $X
MapDrive("g,h,i,j,","$Mapped_drv")
LOOP
CLOSE(5)


Any thoughts?
T.I.A
Frippe

Top
#62422 - 2002-01-26 05:21 PM Re: Mapping variable drive letters from file....
Anonymous
Unregistered


Solved it!!

I added a couple of lines to the "MapDrive" function and, voila!

Here's the code I used:


$srvr = @LSERVER
$q_log_path = $srvr + "\netlogon\Folders.txt"
Function MapDrive($drives,$resource)
   DIM $LastDrive,$drive   
   $drives = split($drives,",")
   $lastdrive = $drives[ubound($drives)]
   for each $drive in $drives
                $drive = $drive + ":"
                IF $drive = ":"
                   exit(1)
                ENDIF
      use $drive $resource
      if @error = 0
         $mapdrive = $drive
         exit(0)
      endif
      if $drive = $lastdrive
         $mapdrive = "N/A"
         exit(1)
      endif
   next
EndFunction

$quota_drive = $srvr + "\"
OPEN(5,$q_log_path,3)
  WHILE @ERROR = 0
  $X = ReadLine(5)
   IF $X = ""
     CLOSE(5)
     Goto Eof
   ENDIF
  $Mapped_drv = $quota_drive + $X
  MapDrive("g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z","$Mapped_drv")
  LOOP
CLOSE(5)
:Eof


//Frippe

[ 26 January 2002: Message edited by: Frippe ]

[ 26 January 2002: Message edited by: Frippe ]

Top
#62423 - 2002-01-26 05:29 PM Re: Mapping variable drive letters from file....
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Frippe,

you are using the @logon server to read the text file from and since the contents will be available on all DCs (replication) it will read the file contents ok, but you also use @lserver to map the drives to. could it be that you are validated by a different DC (server02 ??) than the server where the shares are defined ?
do a "? @lserver" somewhere to find out.

There could also be another problem (permissions etc.) try running the script in debug mode and after the "use $drive: $resource" line in the function, evaluate @error / @serror


you just beat me by a minute or so there

[ 26 January 2002: Message edited by: mvdw ]

_________________________
rgrds, Maarten

Top
#62424 - 2002-01-26 07:06 PM Re: Mapping variable drive letters from file....
Anonymous
Unregistered


Thanks for your reply Maarten!

Actually the whole thing is a part of a bigger script, so "Folders.txt" is in a folder that is shared with the name "log$", so there is no problem with permissions.
The reason for using @LSERVER is that I don't have any DC's.
The script is used in a school with only one NT4 PDC, and the school is so small that they won't need a BDC.

There seemed to be a problem in the line:
use $drive: $resource
so I removed the : and added this line:
$drive = $drive + ":"
After that it worked (more or less).

Thanks again!

regards
Frippe

Top
#62425 - 2002-01-26 08:29 PM Re: Mapping variable drive letters from file....
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
weird... in the final version of the UDF i have that line like this.

use "$drive:" "$resource"

because of that very problem.

Bryce

Top
#62426 - 2002-01-26 09:01 PM Re: Mapping variable drive letters from file....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I wonder if there's any correlation to this and the post below. Could someone shed some light on this? There was another post where the USE command with the drive designator without quotes failed.

mapping drive F:

All examples in the docs are without quotes.

[ 26 January 2002: Message edited by: LLigetfa ]

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

Top
#62427 - 2002-01-28 12:27 AM Re: Mapping variable drive letters from file....
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
I'm still wondering what error message is returned. I have some scripts that do extensive drive mapping repeatedly. If there is some issue with the use command, i'd sure like to know.

Frippe, are you able to recreate the problem and send us output with @error and @serror after the use statement ??

_________________________
rgrds, Maarten

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 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.055 seconds in which 0.026 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