Click to See Complete Forum and Search --> : CGI Upoload error


rakz
09-22-2006, 12:30 AM
Hey guys im having a problem when im running a cgi script
this script is used to run a query to a databse
and then produces a form
the form then can be changed and updated

and submitted to a master pogram

when we are trying to upload this form
the logs are not going to the right folder
preventing the form to be created on the server

how do we define the path that a file is to be created to

the code is as follow
definition of the path
#---------------------------------------------------------------------------
$filesdir = ''; # This needs to be the path to the location of the files
# from the root directory ex. if files are located c:\home\root\usrname\scripts\files
# then $filesdir = scripts\files
# if blank, program will use same directory as cgi directory
#---------------------------------------------------------------------------
setting the variable
my $log_file="exsubmit.log";

and
creating log file

# create log file
log_array(pairs);

the sub routine for errors is this


sub log_line($)
{
my $line = shift;
open( LOG_FILE, ">>$Lfilesdir$log_file" ) or error( "Could not open $Lfilesdir$log_file: $!", 'die', $this_script_name );
print LOG_FILE "[",scalar(localtime), "]",$ENV{REMOTE_ADDR},":",$line,"\n";
close( LOG_FILE );
}
sub log_array($)
{
my $array = shift;
my $line;
foreach ( @$array ) {
$line=$line."$_, ";
}
log_line($line);
}

please advise what i can do to fix the problem

bhammock
09-22-2006, 01:51 AM
If I am ready correctly what you are asking, you will need...

$filesdir = '/home/root/usrname/scripts/files/';

Reasoning:
[1] $filesdir must be the absolute path
[2] / is preferred as to limit conflicts with \ commands
[3] ending / on the $filesdir string is needed to stop your command open( LOG_FILE, ">>$Lfilesdir$log_file" ) from being translated to "/home/root/usrname/scripts/filesexsubmit.log"

I hope that helps! And if I am way off target, then would you at least buy me a beer to help me cope? :p

rakz
09-24-2006, 05:58 PM
ill let u know how it goes