#!/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();