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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data not being saved

Status
Not open for further replies.

mossv2

MIS
Mar 4, 2010
5
US
There are three Perl scripts and the third one should operate on data but isn't. 2.pl should create a file /var/ which it doesn't do.

0.pl
Code:
#!/usr/bin/perl

use CGI;
$query = new CGI;

print $query->header;
print $query->start_html(-title=>'Password');

print "<FONT FACE = 'arial' SIZE = '2'>";
print "<FORM ACTION = '/cgi-bin/1.pl' METHOD = 'post'>";
print "<BR>To begin the session, please enter 
	your Personal Identification Number (PIN) and
	password. </B><BR><BR>";
print "<TABLE>
<TR>
<TD><FONT FACE = 'arial' SIZE = '2'> PIN</TD>
<TD><INPUT TYPE='textbox' NAME='pin' SIZE='25' MAXLENGTH='30'></TD>
</TR>
<TR>
<TD><FONT FACE = 'arial' SIZE = '2'> Password</TD>
<TD><INPUT TYPE='password' NAME='password' SIZE='25' MAXLENGTH='30'></TD>
</TR>
</TABLE>";

print "<INPUT TYPE='submit' VALUE='Submit'>";
print "</FORM>";
print $query->end_html;

1.pl
Code:
#!/usr/bin/perl

use CGI;
$query = new CGI;

$pin= $query->param('pin');
$password= $query->param('password');

print $query->header;
print $query->start_html(-title=>'Demo');
print "<FORM ACTION = '/cgi-bin/2.pl' METHOD = 'post'>";

print "<FONT FACE = 'arial' SIZE = '2'>";

print "<B>Enter User Data Here.</B><BR><BR>";
print "User: <INPUT TYPE='textbox' NAME='username' VALUE=''><BR>";
print "UID: <INPUT TYPE='textbox' NAME='uid' MAXLENGTH='8' VALUE=''><BR>";
print "GID: <INPUT TYPE='textbox' NAME='gid' MAXLENGTH='5' VALUE=''><BR><BR>";

print "<INPUT TYPE='hidden' NAME='pin' VALUE=$pin>";
print "<INPUT TYPE='hidden' NAME='password' VALUE=$password>";
print "<INPUT TYPE = 'submit' VALUE = 'Submit Data'>";
print "</FORM></FONT>";
print $query->end_html;

2.pl
Code:
#!/usr/bin/perl

use CGI;
$query = new CGI;

$pin = $query->param('pin');
$password = $query->param('password');
$username = $query->param('username');
$uid = $query->param('uid');
$gid = $query->param('gid');

$filename = "/var/[URL unfurl="true"]www/data/"[/URL] . $username . ".txt";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year=$year+1900;

system("/usr/bin/touch $filename");
system("/sbin/chown $uid:$gid $filename");

print $query->header;
print $query->start_html(-title=>'Save');

print "<FONT FACE = 'arial' SIZE = '2'>";
print "<FORM ACTION = '/cgi-bin/1.pl' METHOD = 'post'>";
print "<INPUT TYPE='hidden' NAME='pin' VALUE=$pin>";
print "<INPUT TYPE='hidden' NAME='password' VALUE=$password>";
print "Thank you.<BR><BR>";
print "<INPUT TYPE='submit' VALUE='Return to menu'>";
print "</FORM>";
print $query->end_html;
 
Is it a permissions thing? Is your web server allowed to create files outside of its own directory structure, and is it allowed to chown them to someone else? This would require a higher level of permission than you'd normally want to give to a web server process.

Try capturing the response from the system commands, perhaps using qx{"command"}, so you can see the failure.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top