473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Problem in CGI script

hi,

I am trying to create a web application where i have a form to upload a file,which is then processed by a cgi script and gives me out the output,
here is the code which i use,

Expand|Select|Wrap|Line Numbers
  1. # Configuration
  2. my $EXECUTABLE_DIRECTORY = "/web_server/Test";
  3. my $CREATE_DIRECTORY = "//web_server/Output";
  4.  
  5.  
  6. my $cgi = CGI->new();
  7. my $pdb_file = $cgi->param("upfile");
  8. $pdb_file =~ s/.*[\/\\](.*)/$1/; 
  9. die "Missing PDB file \n" if(!$pdb_file);
  10. print STDERR "PDB file is $pdb_file\n";
  11. my $mode = 'SH';                    
  12.  
  13. my $read_file = $cgi->upload("upfile"); 
  14.  open (UPFILE,">$CREATE_DIRECTORY/$pdb_file"); 
  15.  while ( <$pdb_file> )  { 
  16.    print UPFILE; 
  17.    print ;
  18.  } 
  19.  close UPFILE; 
  20.  
  21.  
  22. if ($mode eq 'SH'){
  23.     system "$EXECUTABLE_DIRECTORY/pdb2alm $CREATE_DIRECTORY/$pdb_file > $CREATE_DIRECTORY/query.alm";
  24.     system "$EXECUTABLE_DIRECTORY/command_arg_alm_exp $CREATE_DIRECTORY/query.alm > $CREATE_DIRECTORY/distances_SH.log" ;
  25.     open(IN,"<$CREATE_DIRECTORY/distances_SH.log");
  26.     my $line;
  27.     my %lig_name;
  28.     while($line=<IN>){
  29.         chomp $line;
  30.         my @words = split(' ', $line);
  31.         $lig_name{$words[1]} = $words[0];
  32.         }
  33.     close IN;
  34.     my $count=1;
  35.     foreach my $key (sort { $lig_name{$a} <=> $lig_name{$b} }keys %lig_name){
  36.         open(FILE,"</Users/gunasekp/SH/ligand/ligand_$key.pdb");
  37.         if($count<=10){
  38.             while(<FILE>){
  39.             if($_ =~ /(COMPND)\s+(\w+)\s+(.*)/){
  40.                 print "$count    ",$3,"     ",$lig_name{$key},"\n";
  41.                 }
  42.             }
  43.         }
  44.         $count++;
  45.     }
  46.     ......code continues
  47.  
the problem is when i see the error log it says the

" malformed header from script. Bad header=COMPND Y 2p-DEOXY-N6-(S)STYR: /Users/gunasekp/Sites/cgi-bin/automate_cgi.pl
sh: line 1: /Users/gunasekp/web_server/Output/query.alm: Permission denied
sh: line 1: /Users/gunasekp/web_server/Output/distances_SH.log: Permission denied "

2)(pdb2alm and command_....) are executable c++ files which are placed in a directory in harddisk and whose configuration is (drwxr-xr-x and for files -rwxrwxrwx)
3) the output files like query.alm are written to directory whose configuration is (drwxrwxrwx and for files -rw-r--r--)

help me to solve this problems?

Prasad.
Jan 7 '08 #1
3 1247
numberwhun
3,509 Expert Mod 2GB
hi,

I am trying to create a web application where i have a form to upload a file,which is then processed by a cgi script and gives me out the output,
here is the code which i use,

Expand|Select|Wrap|Line Numbers
  1. # Configuration
  2. my $EXECUTABLE_DIRECTORY = "/web_server/Test";
  3. my $CREATE_DIRECTORY = "//web_server/Output";
  4.  
  5.  
  6. my $cgi = CGI->new();
  7. my $pdb_file = $cgi->param("upfile");
  8. $pdb_file =~ s/.*[\/\\](.*)/$1/; 
  9. die "Missing PDB file \n" if(!$pdb_file);
  10. print STDERR "PDB file is $pdb_file\n";
  11. my $mode = 'SH';                    
  12.  
  13. my $read_file = $cgi->upload("upfile"); 
  14.  open (UPFILE,">$CREATE_DIRECTORY/$pdb_file"); 
  15.  while ( <$pdb_file> )  { 
  16.    print UPFILE; 
  17.    print ;
  18.  } 
  19.  close UPFILE; 
  20.  
  21.  
  22. if ($mode eq 'SH'){
  23.     system "$EXECUTABLE_DIRECTORY/pdb2alm $CREATE_DIRECTORY/$pdb_file > $CREATE_DIRECTORY/query.alm";
  24.     system "$EXECUTABLE_DIRECTORY/command_arg_alm_exp $CREATE_DIRECTORY/query.alm > $CREATE_DIRECTORY/distances_SH.log" ;
  25.     open(IN,"<$CREATE_DIRECTORY/distances_SH.log");
  26.     my $line;
  27.     my %lig_name;
  28.     while($line=<IN>){
  29.         chomp $line;
  30.         my @words = split(' ', $line);
  31.         $lig_name{$words[1]} = $words[0];
  32.         }
  33.     close IN;
  34.     my $count=1;
  35.     foreach my $key (sort { $lig_name{$a} <=> $lig_name{$b} }keys %lig_name){
  36.         open(FILE,"</Users/gunasekp/SH/ligand/ligand_$key.pdb");
  37.         if($count<=10){
  38.             while(<FILE>){
  39.             if($_ =~ /(COMPND)\s+(\w+)\s+(.*)/){
  40.                 print "$count    ",$3,"     ",$lig_name{$key},"\n";
  41.                 }
  42.             }
  43.         }
  44.         $count++;
  45.     }
  46.     ......code continues
  47.  
the problem is when i see the error log it says the

" malformed header from script. Bad header=COMPND Y 2p-DEOXY-N6-(S)STYR: /Users/gunasekp/Sites/cgi-bin/automate_cgi.pl
sh: line 1: /Users/gunasekp/web_server/Output/query.alm: Permission denied
sh: line 1: /Users/gunasekp/web_server/Output/distances_SH.log: Permission denied "

2)(pdb2alm and command_....) are executable c++ files which are placed in a directory in harddisk and whose configuration is (drwxr-xr-x and for files -rwxrwxrwx)
3) the output files like query.alm are written to directory whose configuration is (drwxrwxrwx and for files -rw-r--r--)

help me to solve this problems?

Prasad.
The first thing that you need to do is put the pragmas "use strict" and "use warnings" at the beginning of your script. This will ensure that all is right with syntax and such.

Next, if you look at this line:

Expand|Select|Wrap|Line Numbers
  1. my $CREATE_DIRECTORY = "//web_server/Output";
  2.  
Why is the begining of this double slashed? In the variable before this one, it is single slashed. I can only assume you are working on Unix, and if you are, this should be single slashed.

Regards,

Jeff
Jan 7 '08 #2
that is a typo while copy and paste,
in my code i have only single slash anda ll the pragmas are at the top.,thats a bit of code not the full one.
Jan 7 '08 #3
numberwhun
3,509 Expert Mod 2GB
that is a typo while copy and paste,
in my code i have only single slash anda ll the pragmas are at the top.,thats a bit of code not the full one.
Ok, if that is the case, then I would check all of my permissions, especially on the output directory as you are clearly getting "Permission Denied" errors. Check to ensure that you can create files in that directory as whatever user you are executing as.

Regards,

Jeff
Jan 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ralph Sluiters | last post by:
Hi, i've got a small problem with my python-script. It is a cgi-script, which is called regulary (e.g. every 5 minutes) and returns a xml-data-structure. This script calls a very slow function,...
4
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
9
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
1
by: tehweb | last post by:
Background: I have a fixed position div on the bottom om my page. I have then added a dialog-div into this fixed position one. When I bring up the dialog, everything works if the the scrollTop is...
4
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.