Hi, I am new here and I am also new to Perl.
Perl is a cool language I have to say. BUT..
its doing something crazy..
With my script..
When I want to use substr($record, $FifthCollumEnds, $SixthCollumEnds-1);
it freaks out..
I need to read the Home dir from the file but he reads homedir + the Bash.. :/
Anywho..
here is my script.. I know its still hidious and has lots of comments.. But well:
#!/usr/local/bin/perl
#Show all users in table in the Following format:
#Username | EnabledIcons | <Enabled//Disabled Status> | <edit button>
#On the Button put Button Change Global Settings
print "content-type: text/html
<head><title>iDesk Webmin Module</title></head>
<body>
<TABLE border=3> <TR> <TD><strong>Username</strong></TD><TD><strong>
+Enabled Icons</strong></TD><TD><strong>Status</strong></TD><TD><stron
+g>Running</strong></TD><TD><strong>Edit</strong></TD></TR>";
#Read File /etc/passwd
open (PASSWDFILE, "//etc//passwd");
while ($record = <PASSWDFILE>) {
#Filter out everyone from UID 1000 of Bigger
#Thats the 3th Collum and set %HOMEDIR% to the 6th Collum
$FirstCollumEnds = index($record,":",0) + 1;
$SecondCollumEnds = index($record,":",$FirstCollumEnds) +1;
$ThirthCollumEnds = index($record,":",$SecondCollumEnds)+1;
$FourthCollumEnds = index($record,":",$ThirthCollumEnds)+1;
$FifthCollumEnds = index($record,":",$FourthCollumEnds)+1;
$SixthCollumEnds = index($record,":",$FifthCollumEnds) +1;
#THIRT COLLUM IS 1000 OR HIGHER
#ATTENTION NEEDED:
#Changed to 0 for Debug Reasons.
#Change it back to 1000 when working..
#if(substr($record, $SecondCollumEnds, ($ThirthCollumEnds-$SecondCo
+llumEnds))ge 0) #ge is: >=
#{
#Set %Username% to First Collum Value
$Username = substr($record, 0, $SecondCollumEnds-3); #Dont ask the -3.
+ Dont know why, but it seems to work.. ^^
print "<TD> $Username </TD>";
#Read "ls %HOMEDIR%/.idesktop"
$homedir = substr($record, $FifthCollumEnds, $SixthCollumEnds-1);
#$output = ls("$homedir//.idesktop");
#print "<TD> $output </TD>";
print"<TD>$homedir</TD>";
#DEBUG ONLY
print "<TD>DB:::</TD>";
print "<TD>R: $record</TD>";
print "<TD>A: ($SixthCollemEnd+1)-$FifthCollumEnds</TD>";
print "<TD>F: $FirstCollumEnds </TD>";
print "<TD>S: $SecondCollumEnds </TD>";
print "<TD>T: $ThirthCollumEnds </TD>";
print "<TD>F: $FourthCollumEnds </TD>";
print "<TD>5: $FifthCollumEnds </TD>";
print "<TD>S: $SixthCollumEnds </TD>";
#DEBUG ONLY END
#Read if iDesk files and directorys exist:
#File %HOMEDIR%/.ideskrc and dir %HOMEDIR%/.idesktop
##ATTENTION NEEDED:
#if(($homedir/.idesktop/)&& ($homedir/.ideskrc))
#{print "<TD> FOUND </TD>";} else {print "<TD>
+ Not Found </TD><TD> </TD>";}
#Check if iDesk is running by Person.
##ATTENTION NEEDED:
#And put the edit button down.
##ATTENTION NEEDED:
#print "<TD> <form ONCLICK="window.location.href = ".//ed
+ituser.cgi $Username $homedir""><button>Edit</button></form> </TD>
print"</TR>";
#}else{print"<TD>No Users found.</TD><TD> - </TD><TD> FAILED </TD>
+<TD> FAILED </TD><TD> - </TD></TR>";}
}#Check for another.
close(PASSWDFILE);
#When everything is found do:
##ATTENTION NEEDED:
#print "<form ONCLICK="window.location.href = ".//changeglobal.cgi""
+><button>Change Global Settings</button></form>
# <form ONCLICK="window.location.href = ".//reapply.cgi""><but
+ton>Rebuild All Files</button></form>
print"</body>";
And well the part:
$homedir = substr($record, $FifthCollumEnds, $SixthCollumEnds-1);
#$output = ls("$homedir//.idesktop");
#print "<TD> $output </TD>";
print"<TD>$homedir</TD>";
Also does weird :S
Well, who can help me maybe?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.