here is something I've tried to make out of your code.
I hope, that helps a bit :-))
The vars ending with usr_specific I left empty, so the produced script will redirect to your localhosts root dir when that blank.
#!/usr/bin/perl -w use strict; $|++; use CGI qw/:all /; use CGI::Carp qq/fatalsToBrowser/; my ($q, $basedir, $q_brieftitle, @stored, @output, $line, $rights); my ($dir_usr_specific, $rights_usr_specific, $filetypes_usr_specific, +$domain_usr_specific); $q = CGI->new(); print $q->header(); print $q->start_html(); #####Create Perl upload script $basedir = ".."; $q_brieftitle = "/cgi-bin"; # user sepcific definitions go here $rights = '$basedir = "/home/sites/stuff/users/'.$dir_usr_specific.'"; +'; $rights .= '$allowall = "'.$rights_usr_specific.'";'; $rights .= '$theext = ".'.$filetypes_usr_specific.'";'; $rights .= '$donepage = "'.$domain_usr_specific.'";'; # end user sepcific definitions open (FILE, ">$basedir$q_brieftitle/upload.cgi") || die "blah"; #flock(FILE, 2); # process @stored = <DATA>; foreach $line (@stored) { push @output, $line; if ($line =~ /^\# usr_spec_def/i) { foreach $_ (split (";", $rights)) { push @output, $_.";\n"; } } } print FILE @output; close FILE; print $q->code(pre(@output)), end_html(); # the folllowing DATA section could also be somewhere in a file __DATA__ #!/usr/bin/perl use strict; $|++; use CGI qw/:all/; my ($basedir, $allowall, $theext, $donepage, $req, $onnum); ## DO NOT EDIT OR COPY ABOVE THIS LINE :-) ## # usr_spec_def ## DO NOT EDIT OR COPY BELOW THIS LINE## $req = CGI->new(); $onnum = 1; while ($onnum != 11) { my ($bytesread, $buffer, $filenotgood); my $file = $req->param("FILE$onnum"); if ($file) { my $fileName = $file; $fileName =~ s!^.*(\|\/)!!; my $newmain = $fileName; if ($allowall ne "yes") { if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext +) { $filenotgood = "yes"; } } if ($filenotgood ne "yes") { open (OUTFILE, ">$basedir/$fileName") || die "failed"; print $req->p("$basedir/$fileName"); while ($bytesread = read($file, $buffer, 1024)) { print OUTFILE $buffer; } close OUTFILE; } } $onnum++; } print $req->redirect($donepage);
when I was looking on your code, it was quite helpful to me, that this one gives the content of the created file to the browser(screen).
I hope by now, I understood, what you are trying to do :-))
have a nice day

In reply to RE: CGI Question by little
in thread CGI Question by koacamper

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.