I have to create a directory structure of HTML redirects. I am sure there are many much more efficent ways of doing this but we do not have control of the server and this is what they want. Each redirect points to a script on another site.
This said the resulting directory structure will be a directory with a name and the index.html file that points to the CGI Script. The problem is when I try to create the directories and then chmod them the file permissions are not set; and I get this error :
No such file or directory
I am trying for now to set the directory to ./ since it makes for easier testing but eventually it will go to another directory elsewhere. Thus I made it so that it takes in "directory path" of some sort and the name of the Directory. So what you should get is "path_from_root/directory_name" in my default case I get ./directory name. It makes the directory fine, it writes the Redirect fine but the permissions that are set will not let me read or write to the directory ( and I am chmodding to 755 ). Here is the code any ideas why it is not chmodding correctly?<\p>
sub make_alias( $ )
{
my $self = shift;
my $name = $_[0];
my $id = $_[1];
my $alias_data = "alias.db";
my $alias_directory = "./";
print "$name,$id \n";
#create directory for redirect to go into
my $path = $alias_directory . $name;
my $mode = "0755";
print "path = $path \n";
mkdir $path, $mode;
print "x = $! , $path \n";
chmod( $mode, $path );
#add redirect file
my $redirect = new Redirect();
$redirect->redirect_filename( $path . "\/index.html" );
$redirect->redirect_link( "http://www.nowhere.com/cgi/school_
+connection.cgi?id=$_[1]" );
$redirect->displayed_link( "" );
$redirect->redirect_template( "redirect_template.html" );
$redirect->redirect_delay( "0" );
$redirect->create_redirect;
$redirect->save_redirect or die $!;
print "After redirect saved \n";
#add to database
my $db = new Database();
$db->file($alias_data);
$db->delimiter("|");
$db->execute( "insert", "Name", $name, "ID", $id );
return 1;
}