I have this code that parses smb.conf and puts a users shares/descriptions into a hash of the username:
open(CONFIG, "$smbconf") || die;
while (<CONFIG>) {
next unless m/^\[([a-zA-Z0-9]+)\]$/;
$ShareName = $1;
while (<CONFIG>) {
next unless m/^\s+comment \= (.*)$/;
$ShareDesc = $1;
while (<CONFIG>) {
next unless m/^\s+valid users \= (.*)$/;
@ValidUsers = split(",", $1);
foreach $USER(@ValidUsers){
$$USER{$ShareName} = "$ShareDesc";
}
last;
}
last;
}
}
close(CONFIG);
I'm having problems passing a username into a function to pull out the stored hash values:
sub get_user_shares {
$username=@_;
while( ($key, $value) = each(%$username) ) {
printf "%-12s %30s\n", $key, $value;
}
}
$USERNAME = "smbuser01";
&get_user_shares("$USERNAME");
'%$username' does not eval to '%smbuser01'. I've tried using eval w/o success. Maybe i'm missing something...
Any ideas?
Thanks in advance,
jim
open(CONFIG, "$smbconf") || die;
while (<CONFIG>) {
next unless m/^\[([a-zA-Z0-9]+)\]$/;
$ShareName = $1;
while (<CONFIG>) {
next unless m/^\s+comment \= (.*)$/;
$ShareDesc = $1;
while (<CONFIG>) {
next unless m/^\s+valid users \= (.*)$/;
@ValidUsers = split(",", $1);
foreach $USER(@ValidUsers){
$$USER{$ShareName} = "$ShareDesc";
}
last;
}
last;
}
}
close(CONFIG);
I'm having problems passing a username into a function to pull out the stored hash values:
sub get_user_shares {
$username=@_;
while( ($key, $value) = each(%$username) ) {
printf "%-12s %30s\n", $key, $value;
}
}
$USERNAME = "smbuser01";
&get_user_shares("$USERNAME");
'%$username' does not eval to '%smbuser01'. I've tried using eval w/o success. Maybe i'm missing something...
Any ideas?
Thanks in advance,
jim