Page 1 of 1 1
Topic Options
#21818 - 2002-05-21 12:09 AM creating shares... The hard way...
MeneM Offline
Lurker

Registered: 2002-05-20
Posts: 4
Loc: Amsterdam
Hi all,

I'm new to kixtart. But I can already say it is one of the more handy things to know. I'm also proud that it was a dutchman who invented it. Ofcourse with the input of many others.

I would like some help on the following piece of code wich i cannot get to work properly:
code:
$server = server
$shares = Mark,www,hdd,Public
$drives = e:,f:,g:,h:
$I = 0

FOR EACH $mapping IN $shares
use $drives[$I] \\$server\$mapping
$I = $I + 1
NEXT

I think it obvious what I want it to do, but it wont work right. So... What am I doing wrong?

Mark

Top
#21819 - 2002-05-21 12:20 AM Re: creating shares... The hard way...
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

I think your values should be in speech marks. EG:

code:
  
$server = "server"
$shares = "Mark","www","hdd","Public"
$drives = "e:","f:","g:","h:"
$I = 0
FOR EACH $mapping IN $shares
use $drives[$I] \\$server\$mapping
$I = $I + 1
NEXT

Darren
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#21820 - 2002-05-21 12:25 AM Re: creating shares... The hard way...
MeneM Offline
Lurker

Registered: 2002-05-20
Posts: 4
Loc: Amsterdam
What a mistaike to maike...

Well changed that bit, although Those shares are not created yet. Bummer.

Any other idea's?

Mark

Top
#21821 - 2002-05-21 12:34 AM Re: creating shares... The hard way...
MeneM Offline
Lurker

Registered: 2002-05-20
Posts: 4
Loc: Amsterdam
In this try I made sure $I is an integer and not a string. So it now looks like this:
code:
$server = "server"
$shares = "Mark","www","hdd","Public"
$drives = "e:","f:","g:","h:"
$I = "0"
$I = val("$I")

FOR EACH $mapping IN $shares
use $drives[$I] \\$server\$mapping
$I = $I + 1
NEXT

And guess what? It still won't work...

Mark

Top
#21822 - 2002-05-20 01:49 PM Re: creating shares... The hard way...
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Try this:

code:
$server = "server"
$shares = "Mark","www","hdd","Public"
$drives = "e:","f:","g:","h:"
$I = 0
FOR EACH $mapping IN $shares
$assign = $drives[$i]
$nul = execute('use $assign "\\$server\$mapping"')
$I = $I + 1
NEXT

_________________________
Dean

Top
#21823 - 2002-05-20 03:05 PM Re: creating shares... The hard way...
MeneM Offline
Lurker

Registered: 2002-05-20
Posts: 4
Loc: Amsterdam
Hell yeah!
That worked!

I'm so glad. Thank you.

Maybe you would care to explain to me what I did wrong/Why it did not work?

Mark

Top
#21824 - 2002-05-20 03:26 PM Re: creating shares... The hard way...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Try this, I formatted the code properly. The backslashes have been put in quotes.
code:
$server = "server"
$shares = "Mark","www","hdd","Public"
$drives = "e:","f:","g:","h:"
$I = 0
FOR EACH $mapping IN $shares
USE $drives[$I] '\\'+$server+'\'+$mapping
$I = $I + 1
NEXT

As an alternative, you might want to put your mappings configuration into a .INI file. This way you can update drive mappings without changing the script code. An example for printer mappings is provided here: http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=1;t=004838
It would be very easy to translate it for drive mappings.
_________________________
There are two types of vessels, submarines and targets.

Top
#21825 - 2002-05-20 03:28 PM Re: creating shares... The hard way...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Dean, did you just deleted you post that I was replying to?]

Dean:

Kixtart can accept a variable as drivename, e.g.
code:
$drive='y:'
$share='\\server\share'
USE $drive $share

will work just fine.

[ 20 May 2002, 15:29: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#21826 - 2002-05-20 03:33 PM Re: creating shares... The hard way...
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Jens -

Yes, I deleted my post since it contained incorrect information. Thank you for providing the proper solution. I'm just not in the "CODE MODE" today. [Smile]
_________________________
Dean

Top
#21827 - 2002-05-20 03:44 PM Re: creating shares... The hard way...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I guess you're just not Caffeinated enough yet [Big Grin]

[ 20 May 2002, 15:44: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 584 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.03 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