By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,183 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,183 IT Pros & Developers. It's quick & easy.

Premature end of script

rajiv07
100+
P: 141
Hi to all this is the code i am using to do some task but it gives the following error.i am breaking my head why the error is coming please help me on this.

The Error in log file.

(2)No such file or directory: exec of '/var/www/cgi-bin/xone/query/store_login.pl' failed

Premature end of script headers: store_login.pl


The Script

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use CGI;
  3. use DBI;
  4. use CGI::Carp qw(fatalsToBrowser);
  5. use CGI::Cookie;
  6.  
  7. my $cgi=new CGI;
  8.  
  9. my  $cStore_Id=$cgi->param('storeid');
  10.  
  11. my $cUser_Name=$cgi->param('username');
  12.  
  13. my $cPassword=$cgi->param('password');
  14.  
  15. my $cSite=$ENV{'HTTP_HOST'};
  16.  
  17. my $cPrev=$ENV{'HTTP_REFERER'};
  18.  
  19. if($cPrev=~/$cSite/)
  20. {
  21. }
  22. #else
  23. #{
  24. #print "Content-type:text/html\n\n";
  25. #print "You Cannot View this Page";
  26. #exit;
  27. #}
  28.  
  29. my $dbh=DBI->connect('dbi:mysql:xone:localhost','root','') or die "cannot connect to the database $DBI::errstr";
  30.  
  31. if(($cStore_Id eq "")&&($cUser_Name eq "")&&($cPassword eq ""))
  32. {
  33.  &_showForm();
  34. exit;
  35. }
  36.  
  37. my $cStr="select xstore_managerinfo.username,xstore_managerinfo.password from xstoreinfo,xstore_managerinfo where xstoreinfo.storeid=\'$cStore_Id\' and xstore_managerinfo.password=\'$cPassword\' and xstore_managerinfo.username=\'$cUser_Name\' and xstore_managerinfo.storeid=xstoreinfo.storeid";
  38.  
  39. my $cSth=$dbh->prepare($cStr);
  40.  
  41. $cSth->execute();
  42.  
  43. @aTemp=$cSth->fetchrow_array;
  44.  
  45. if($aTemp[0] eq "")
  46. {
  47. &_showErrorPage();
  48. exit;
  49. }
  50.  
  51. my $server = $ENV{'HTTP_HOST'} ;
  52.  
  53. my $path = "/" ;
  54.  
  55. print "Set-Cookie: manager\=$cUser_Name; path\=$path;\n";
  56.  
  57. print 'Status: 302 Moved', "\r\n",'Location:/cgi-bin/xone/query/billgenerate.pl', "\r\n\r\n";
  58.  
  59. sub _showForm
  60. {
  61. #my $cStr="select storeid from xstoreinfo where storeid=\'1123\'";
  62. #
  63. #my $cSth=$dbh->prepare($cStr);
  64. #
  65. #$cSth->execute();
  66. #
  67. #@aTemp=$cSth->fetchrow_array;
  68.  
  69. my $cFile="../templates/store_login.html";
  70.  
  71. my $cTemplate=_ReadFile($cFile);
  72.  
  73. #$cTemplate=~ s/__STOREID__/$aTemp[0]/ig;
  74.  
  75. my $cMain_File="../templates/store_template.html";
  76.  
  77. my $cMain_Template=_ReadFile($cMain_File);
  78.  
  79. $cMain_Template=~ s/__STORE_BILL__/$cTemplate/;
  80.  
  81. print "Content-type:text/html\n\n";
  82. print $cMain_Template;
  83. return; 
  84. }
  85.  
  86. sub _ReadFile
  87. {
  88. my $cFile=shift;
  89.  
  90. open(IN,"$cFile");
  91.  
  92. my $cTemp=$/;
  93.  
  94. undef $/;
  95.  
  96. my $cOut=<IN>;
  97.  
  98. $/=$cTemp;
  99.  
  100. undef $cTemp;
  101.  
  102. close(IN);
  103.  
  104. return $cOut;
  105. }
  106.  
  107. sub _showErrorPage
  108. {
  109. my $cFile="../templates/error_page.html";
  110.  
  111. my $cTemplate=_ReadFile($cFile);
  112.  
  113. my $cMain_File="../templates/store_template.html";
  114.  
  115. my $cMain_Template=_ReadFile($cMain_File);
  116.  
  117. $cMain_Template=~ s/__STORE_BILL__/$cTemplate/;
  118. print "Content-type:text/html\n\n";
  119. print $cMain_Template;
  120. return;
  121. }
Actually this script is running successfully on some other server.But i try to run in my new server it gives that error.
Thanks
RajivGandhi
Feb 15 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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