flyPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am working on a bioinformatics application using cgi-PERL, where I ask for two file as input and analyze two files to give ouput.

I used this to get the file path
print "<input name=t type=file />";

and used POST to pass the value to another .pl file where the file whose path was given is analyzed and output was displayed.

When I was running the application on localhost, its working fine. But it doesnot run on server. Can you please tell me what changes I have to make in my cgi-perl code so that it can analyze a file whose path is goven on the server.

I guess i need to upload the file first on server. I can't get the funda involved, I searched everywhr but cudn get it.

Replies are listed 'Best First'.
Re: Upload file (PDB format ) on server
by marto (Cardinal) on May 28, 2009 at 08:29 UTC

    In addition to the advice you have already been given, saying 'it doesnot run on server' isn't very helpful. Can you tell us more information, such as:

  • Do you receive an error message when running your script?
  • Does your web servers error log show any problems?
  • What Operating system and web server application are you using?
  • Also see How do I post a question effectively?.

    Martin

      thnx for the reply.

      No i dint get any message

      my code of the called file is

      print "Content-type: text/html\n\n";

      $_="My Page";
      $datalen=$ENV{'Content_Length'};
      read(STDIN,$q,$datalen);
      @data=split(/&/,$q);
      $len=@data;
      for($i=0; $i<$len; $i++)
      {
      $data=@data$i;
      $data=~ s/\s|t=|RUN//g;
      @data$i=$data;
      }
      $a1=(@data[0]);

      $a1 gets the file path,like C:Projecct\jeisika\mol.pdb
      which i plan to open and analyze, whereas, when made to run on server this file path comes to perl file as "mol.pdb" only!
      This is the first problem

      and the second is that i dont know whether i have to upload this file to server before running. Cannot it be done by browsing the file path and then POST it to the second pearl file where this file should be opened and analysed??

      I hope im clear now..... :)
        $a1 gets the file path,like C:Projecct\jeisika\mol.pdb
        which i plan to open and analyze, whereas, when made to run on server this file path comes to perl file as "mol.pdb" only!

        Why do you need the entire path to the file?  On the remote machine you have a different file system, where that path will most likely not be valid anyway...  Most browsers (except some versions of IE) are aware of this, and simply strip the directory component of the local path — in part because it may unnecessarily disclose private details of your local machine.

        If you want to analyse the contents of the file, there is no way around uploading those contents to the server, as the server cannot access C:Projecct\jeisika\mol.pdb on your local filesystem.  Read what the Anonymous Monk pointed to on how to upload files via CGI.

        $datalen=$ENV{'Content_Length'}; read(STDIN,$q,$datalen); @data=split(/&/,$q);

        I guess you would save yourself a lot of pain if you used CGI instead, which parses CGI parameters and handles uploading of files for you.

Re: Upload file (PDB format ) on server
by Anonymous Monk on May 28, 2009 at 08:13 UTC