Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some help please

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I'm making a part for my perl script to view administrators for my control panel.

It is supposed to take the username and password and put it in a table.

Here is what my code for that sub routine looks like:

sub view_admins {

print "Content-type: text/html\n\n";

open (FILE, ">/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi");
foreach my $username (keys %admin_profile) {
$admin_list = &quot;<TR><TD>$username</TD><TD>$admin_profile{$username}</TD></TR>&quot;;
}
close FILE;
chmod(0777, &quot;/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi&quot;);

print<<THIS;
<P>
<CENTER>
<TABLE WIDTH=&quot;92%&quot; BORDER=&quot;1&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
<TR>
<TD><B>Username</B></TD><TD><B>Password</B></TD>
</TR>
$admin_list
</TABLE>
</CENTER>

THIS

}


When I go to the admin file I get the following error:

/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi did not return a true value at /home/puremadnezz/cgi-bin/test/admin.cgi line 10.

Like 10 on my script is:

require &quot;/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi&quot;;

I know I am doing somthing totally wrong, but I can't find the problem. Please help me.

Also I was wondering if someone can write me a sub routine to delete administrators?

Thank you!! :-D
 
Okay, I just found out that:

open (FILE, &quot;>/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi&quot;);
foreach my $username (keys %admin_profile) {
$admin_list = &quot;<TR><TD>$username</TD><TD>$admin_profile{$username}</TD></TR>&quot;;
}
close FILE;
chmod(0777, &quot;/home/puremadnezz/cgi-bin/test/variables/vars_admin.cgi&quot;);


... overwrites vars_admin.cgi making it blank, causing the error to occur.

So... how do I go about completing this part of my script...? :-)
 
Since you are already requiring the file to get the values in it, you shouldn't need to open it at all. The reason it's being overwritten is the > character in your open statement. That for WRITING to a file. If you want input, leave it off or use < instead. But... like I said at the start: you are using require to get the values into your program, so you shouldn't need to open it at all.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top