Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New host, I need help.

Status
Not open for further replies.

Zas

Programmer
Oct 4, 2002
211
US
I've recently moved to a new host (simplehost.com). It took me a while to actually get a script to actually run. The first thing that was wrong was I kept getting a 500 Internal Error- I fixed that by setting the attributes to the script, and than re-uploading it (no idea why that worked). The second error I am stuck on, is why the paths are messed up. I'm getting an error like it cannot find the paths, or there its not being able to write. The script is good, but the path is not found. The error is this:
Content-type: text/html
Software error:
Couldn't open file for writing! at /usr/home/valuico/cgi-bin/stats.pl line 136.
For help, please send mail to the webmaster (support@simplehost.com), giving this error message and the time and date of the error.

This script is flawless on the other host, but due to complications, I had to move. At first, I tried to make it open $cid = "user/$lccname/$lcpassl" (because the script was in the cgi-bin folder), but that failed so I also tried the direct path "
The raw access logs which I cannot make heads of tails of are:
65.27.146.10 - - [12/Aug/2003:14:16:59 -0400] "POST /cgi-bin/login.pl HTTP/1.1" 200 94 " "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YComp 5.0.0.0; Roadrunner; .NET CLR 1.1.4322)"
65.27.146.10 - - [12/Aug/2003:14:31:56 -0400] "GET /cgi-bin/logout.pl HTTP/1.1" 403 227 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YComp 5.0.0.0; Roadrunner; .NET CLR 1.1.4322)"
65.27.146.10 - - [12/Aug/2003:14:32:10 -0400] "GET /cgi-bin/logout.pl HTTP/1.1" 200 4165 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YComp 5.0.0.0; Roadrunner; .NET CLR 1.1.4322)"
65.27.146.10 - - [12/Aug/2003:14:37:45 -0400] "POST /cgi-bin/signup.pl HTTP/1.1" 200 317 " "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YComp 5.0.0.0; Roadrunner; .NET CLR 1.1.4322)"


Please help, ~Z.

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
ok. so i've located the error. for some reason its not letting me write files. reading is fine.

$goldp = int($gold / 200);$power = $age + (($chi + $str + $dex + $force) * 5) + $goldp;
open(DN, &quot;$rdir/databasen.txt&quot;); $DN=<DN>; @DN = split /::/, $DN; close DN;
open(DP, &quot;$rdir/databasep.txt&quot;); $DP=<DP>; @DP = split /::/, $DP; close DP;
$npt = &quot;-1&quot;; foreach $FDN (@DN) {
if (($cname ne $FDN) && ($donep ne &quot;1&quot;)) { $npt = $npt + 1; }
if (($cname eq $FDN) && ($donep ne &quot;1&quot;)) { $donep = 1; } }
open(DPE, &quot;>$rdir/databasep.txt&quot;); close DPE;
$npp = &quot;-2&quot;; foreach $FDP (@DP) { $npp = $npp + 1; open(DPT, &quot;>>$rdir/databasep.txt&quot;);
if ($npp ne $npt) { print DPT &quot;$FDP\::&quot;; } if ($npp eq $npt) { print DPT &quot;$power\::&quot;; } close DPT; } $lcpass = lc($pass); $file = &quot;$cid.txt&quot;; deleteStuff(); sub deleteStuff { unlink($file) or &quot;Error deleting file ($file).txt\n&quot;; }
open(DAT,&quot;>$cid.txt&quot;) or die(&quot;Couldn't open file for writing!&quot;);
print DAT join &quot;::&quot;,$cname,$lcpass,$sex,$align,$icon,$hcolor,$ecolor,$pet,$chi,$str,$dex,$luck,$force,$sa,$sl,$race,$job,$email,$age,$rdir,$gold,$power;
close DAT;

sub error {
print &quot;$_[0]&quot;;
exit;
}


when i remove that, it works fine, otherwise i get that error.

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
mainly the problem is &quot; or die(&quot;Couldn't open file for writing!&quot;)&quot;. why isn't that working?

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
no the problem is its not writing.. the &quot;die&quot; was doing its job. so why is it reading but not writing? the permissions are 777... please help

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
Try moving the files you write to into your home directory, or a subdirectory in your home directory. Many hosts won't allow files to write to directories outside of where your HTML files are located - especially the CGI-BIN directory. This is a security issue - potentially, anybody could upload a file to this directory and cause it to reek havoc on the server(s).

There's always a better way. The fun is trying to find it!
 
ok here is the deal the system admin set the permissions of the directory execute & read more than likely no writing allowed. When a person connects to the cgi it is the user doesn't have write bit set. ie it can not make a new file. To dodge this

#make a file and ftp it to the server
#copy this temp file to the correct location with
rename(&quot;temp.db&quot;, &quot;$path/$filename&quot;) || print &quot;$error&quot;;
#set the permissions can't be changed by you which #means getting the admin to delete it and that pisses them off
chmod(0755, &quot;$path/$filename&quot;) || print &quot;$error&quot;;

#open the file for reading & writing

one last hint -Tw this can keep you from making some dumb mistakes when using cgi on someone elses servers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top