[wellylug] Issues with a perl script
Joe Cook
joe.cook at xtra.co.nz
Fri Oct 20 20:39:34 NZDT 2006
On Thu, 26 Oct 2006 10:28, Geraint M. Jones wrote:
> I have the following script from a book (about windows & linux
> intergration)
>
> #!/usr/bin/perl -w
> my $line;
> mkdir(/profiles/, 0755);
> open(USERS, "/usr/bin/getent passwd|");
> while ($line = <USERS>) {
> my ($name, $password, $uid, $gid) = split(/\:/, $line);
> if ($name !~ /^[\w\ \-\+]+$/) {
> next;
> }
> if (-e "/profiles/$name") {
> next;
> }
> if (($uid =~ /^\d+$/) && ($gid =~ /^\d+$/))
> {
> mkdir("/profiles/$name", 0700);
> chown($uid, $gid, /profiles/$name);
> }
> }
> close(USERS);
>
> however it fails with the following errors
>
> [root at ella ~]# ./makeprofile.pl
> Scalar found where operator expected at ./makeprofile.pl line 16, near
> "/profiles/$name"
> (Missing operator before $name?)
> syntax error at ./makeprofile.pl line 16, near "/profiles/$name"
> Execution of ./makeprofile.pl aborted due to compilation errors.
>
> Unfortunately I know no perl - anyone see any glaring problems with it ?
>
> G
>
>
> --
> This e-mail and any attached files are confidential and may be legally
> privileged. If you are not the addressee, any disclosure, reproduction,
> copying, distribution, or other dissemination or use of this communication
> is strictly prohibited. If you have received this transmission in error
> please notify the sender immediately and then delete this mail. E-mail
> transmission cannot be guaranteed to be secure or error free as information
> could be intercepted, corrupted, lost, destroyed, arrive late or
> incomplete, or contain viruses. The sender therefore does not accept
> liability for any errors or omissions in the contents of this message which
> arise as a result of e-mail transmission or changes to transmitted date not
> specifically approved by the sender. If this e-mail or attached files
> contain information which do not relate to our professional activity we do
> not accept liability for such information. This email has been scanned for
> all currently known viruses by Proxmox v1.5
I am not a perl scripter either but there seem to be some odd things in that
code.
1) Looks like you need quotes around /profiles/$name
{
> mkdir("/profiles/$name", 0700);
> chown($uid, $gid, /profiles/$name);
> }
2) line 3 . need quotes around /profiles/
> mkdir(/profiles/, 0755);
After that it compiles. After that I have no idea.
Good luck!
Joe
More information about the wellylug
mailing list