Logon script generation problem
Kevin Myer
kevin_myer at elanco.k12.pa.us
Tue Oct 19 14:00:11 GMT 1999
Hello,
This should probably be subtitled "A Dumb Perl Programming Error By Kevin"
but I can't track down this bug for the life of me. I have a logon script
generator, written in perl, that contains a few conditional statements.
Depending on the logon username, it will conditionally map more drives.
The problem is my "if" statement only seems to work for numeric values -
it treats all text values as true. More than likely, Perl handles text
values differently than numerical values but I can't seem to find the
answer to this.
>From smb.conf:
[netlogon]
comment = Network Logon Service
path = /usr/local/samba/netlogon
; force user = nobody
locking = No
guest ok = no
root preexec = /usr/local/samba/bin/makelogonscript "%U" %m
^^^^^^
This is to accomodate
usernames with spaces
root postexec = rm /usr/local/samba/netlogon/%U.bat
browseable = no
and /usr/local/samba/bin/makelogonscript is:
#!/usr/bin/perl
open LOGON,">/usr/local/samba/netlogon/$ARGV[0].bat";
print LOGON "NET USE H: \\\\GNEISS\\$ARGV[0]\r\n";
print LOGON "NET TIME \\\\GNEISS /YES /SET\r\n";
print LOGON "REM $ARGV[0]\r\n";
if ( $ARGV[0] == "patron" )
{
print LOGON "REM 2 $ARGV[0]\r\n";
print LOGON "NET USE F: \\\\GNEISS\\LMC\r\n";
print LOGON "NET USE N: \\\\GNEISS\\ACCESSPA\r\n";
print LOGON "NET USE O: \\\\GNEISS\\CHOICES\r\n";
print LOGON "NET USE P: \\\\GNEISS\\EXEGY\r\n";
print LOGON "NET USE Q: \\\\GNEISS\\SIRSCD1\r\n";
print LOGON "NET USE R: \\\\GNEISS\\SIRSCD2\r\n";
print LOGON "NET USE S: \\\\GNEISS\\MASFTE1_EBS\r\n";
print LOGON "NET USE T: \\\\GNEISS\\MASFTE2_EBS\r\n";
print LOGON "NET USE U: \\\\GNEISS\\MASFTE3_EBS\r\n";
print LOGON "NET USE W: \\\\GNEISS\\MASFTE5_EBS\r\n";
print LOGON "NET USE X: \\\\GNEISS\\MASFTE6_EBS\r\n";
print LOGON "NET USE Y: \\\\GNEISS\\MASFTE7_EBS\r\n";
print LOGON "NET USE Z: \\\\GNEISS\\MASFTE8_EBS\r\n";
}
if ($ARGV[0]=="1005" || $ARGV[0]==1008)
{
print LOGON "NET USE I: \\\\GNEISS\\CHOICES2000\r\n";
}
close LOGON;
---------
Now the problem: if $ARGV[0] is numeric, the first if statement is false,
the second is true and the logon script that is generated is:
NET USE H: \\GNEISS\1008
NET TIME \\GNEISS /YES /SET
REM 1008
NET USE I: \\GNEISS\CHOICES2000
But for any textual value of $ARGV[0], such as patron, business ed,
circulation - whatever - the first if statement is always evaluated as
true. Yet when I print out the value of $ARGV[0] inside the statement, its
always what I expect it to be.
So my question is:
Why does <ANYTHING TEXT> always == "patron" ??
Like I said, its got to be some sort of text/numeric thing, in the way
that perl treats strings. Am I using the wrong conditional statement -
does "if" only operate on scalars?
Thanks for any help. I realize this is marginal to Samba NT-DOM
discussions and more a perl question but my Samba NT-DOM users are getting
alot of extra drives mapped and I'm stuck and hoping some perl hacker on
the list can help :(
Kevin
--
~ Kevin M. Myer
. . Network/System Administrator
/V\ ELANCO School District
// \
/( )\
^`~'^
More information about the samba-ntdom
mailing list