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; }

In reply to Making Directories by Angel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.