I am trying to get a cgi script working but it's unable to find a file it requires.

The cgi script is located in my /public_html/cgi-bin (of course) and my file in a directory called /public_html/uploadedfiles

I don't understand why my script is not finding the file ... it is certainly there and at that location.

Code follows

#!/usr/bin/perl -wT # # # # ensure all fatals go to browser during debugging and set-up # comment this BEGIN block out on production code for security BEGIN { $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); } use strict; use warnings; use diagnostics; use CGI qw/:standard/; #print "Content-type: text/html\n\n" # # Upload directory for files # my $upload_dir = "/home/me/uploaded_files"; my $file = "file.txt"; # # Path to PDB processing program # my $program = "/home/me/programs/program"; # # Get the name of the file to process from the command line # Later we will get this from the input to the CGI program # #my $input_file = shift; my $input_file = "$file"; #die "Usage: $0 INPUT_FILENAME\n" unless $input_file; #die "Can't process '$upload_dir/$input_file': File does not exist!\n" # unless -f "$upload_dir/$input_file"; # # Create web page... # print start_html("Processing PDB file '$input_file' ..."), $/, h1("Processing PDB file '$input_file' ..."), $/; chdir $upload_dir; die "Usage: $0 INPUT_FILENAME\n" unless $input_file; die "Can't process '$upload_dir/$input_file': File does not exist!\n" unless -f "$upload_dir/$input_file"; open (PROG, "| $program") || die "Can't run '$program': $!\n"; print PROG "$input_file\n"; close(PROG); print p("OK .. working thus far"), end_html();
Any help much appreciated

In reply to where art thou file? by Angharad

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.