Aggghhh - Problem writing a file to server

11-23-03, 09:30 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Aggghhh - Problem writing a file to server
Well I think Id better ask before doing that again....
I was trying to make my pl script write a new file on the server. The thing would not work and so I had a mess about with it and found it would write the file np in the same directory but when I wanted to write it 2 tree's further up it just wouldnt do it. I thought of making escape chr to see if that was the problem but my pc crashed and burned when I enterned the script. I was then faced with scan disk (xp-pro) finding curupted cache in IE temp internet files folder. I was then faced with nview.dll inistilization routine failed message then when I went back to the site to see if it had worked anyhow the path to where it was supposed to be wrote to reported that it was unable to find the file! Then a box popped up saying that I had 2min to save my work and it was goin to restart my pc. (Remote procedure call RPC, service terminated unexpectantly)
It seems to be alright now but Im off to back up my site!
Anyway the script is as follows;
open (NEWMESSAGE, ">internal/Boardsys/General/GEN$indexnumber.pl");
print NEWMESSAGE "$line1";
print NEWMESSAGE "$line2";
print NEWMESSAGE "$line3";
print NEWMESSAGE "$line4";
print NEWMESSAGE "$line5";
print NEWMESSAGE "$line6";
print NEWMESSAGE "$line7";
print NEWMESSAGE "$line8";
print NEWMESSAGE "$line9";
print NEWMESSAGE "$line10";
print NEWMESSAGE "$line11";
print NEWMESSAGE "$line12";
print NEWMESSAGE "$line13";
print NEWMESSAGE "$line14";
print NEWMESSAGE "$line15";
print NEWMESSAGE "$line16";
print NEWMESSAGE "$line17";
print NEWMESSAGE "$line18";
print NEWMESSAGE "$line19";
print NEWMESSAGE "$line20";
print NEWMESSAGE "$line21";
close (NEWMESSAGE);
Please ignore the terrible primate programming tackticks of 21 lines of output!
This scripts will not write to the dir shown
...SAGE, ">internal/Boardsys/General/GEN$indexnumber.pl");
It will however write with the following format but it in the wrong place!
SAGE, ">GEN$indexnumber.pl");
WARNING DONT TRY THIS OUT!!!!!
The thing that caused my pc to crash and report lots of errors!
SAGE, ">internal\/Boardsys\/General\/GEN$indexnumber.pl");
Can anyone help?
Thanks
DAL
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-23-03, 10:35 AM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try changing:
to:
and post the error message from your error_log. You should always test your opens and closes to be safe.
~Charlie
|

11-23-03, 10:58 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Chas
I have done what you have suggested and I have gone into my /logs/ folder. In there I have an index.html file which I have run and went through everything in there. Also there is ftp.log file which contains ftp logs for access. Also another folder called traffic which I have had a look in but all thats in there is how many MB's Ive used and how much traffic allowance I have left. Cant find where my actual error.log file is....infact if I remember rightly my host doesnt give me access to them.
Nice try but Im just going to have to get the right script for open as I cant get the answer by your wise ways of looking at logs. My old ISP gives me these logs np and I have solved many issues with them. Shame their not on this server (That I can gain access to anyhow)
Can you suggest anything else.
Thanks
DAL
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-23-03, 12:45 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by DAL
Can you suggest anything else.
|
Yep. Try adding this line right under the shebang line in your code:
Your code is fine. My guess is that something is screwed up with the pah you are using. Only the error_log will tell you exactly what's wrong. With CGI::Carp, it will print the error to the screen.
~Charlie
|

11-23-03, 01:04 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well that that .... THERE ARE NO FATALS _ Infact everything runs as it should do! Except the file isnt there??
I run the script from this dir
(If I make it so the script put the file also in this dir then it does this without a problem.)
ROOT>INTERNAL
The script is supposed to write to the following but doesnt
ROOT>INTERNAL>BOARDSYS>GENERAL>
No errors ...the output file just isnt there?
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-23-03, 01:16 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by DAL
The script is supposed to write to the following but doesnt
ROOT>INTERNAL>BOARDSYS>GENERAL>
|
That could be your problem. You're using relative paths instead of absolute paths. Right now, your script is writing the file to:
/path/to/script/internal/Boardsys/General/GEN$indexnumber.pl
not:
/internal/Boardsys/General/GEN$indexnumber.pl
Try putting a / at the beginning of your path and see what happens.
On a side note: If you have the die in your open statement in the script and the use CGI::Carp statement, you should be dieing out because the directory doesn't exist or the file/directory isn't writable. I won't just not write the file.
~Charlie
|

11-23-03, 01:25 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Agggggghhhhh x 10
Tried both
/internal/boardsys/general/GEN$indexnumber.pl
and
/boardsys/general/GEN$indexnumber.pl
both do not show errors nor do they actually apear on the server.
Ive even had alook at the permissions of folders to see if that makes any difference - I have them set for write for user & groups
I have not got any errors other than the ones I used for escape chr
\/internal\/boardsys\/general\/GEN$indexnumber.pl
Dont try this at home kids ! =)
I know this sounded so simple even I should have been able to sort it out but it now looks like my server is connected to /internal/boardsys/twighlight zone!!!
Please please more suggestions
Thanks
DAL
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-23-03, 01:32 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can you post the entire script as an attacment for me to look at? Or PM/email it to me? I can't see why it isn't working.
~Charlie
|

11-23-03, 01:53 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok I sent the script via PM to u Chas
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-23-03, 03:00 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Chas for looking at the script !
Right I can now see the problem (That doesnt mean to say I can understand it!)
----The following is me thinking out-loud---------------
Software error:
Unable to write open file. Reason: No such file or directory at /homepages/39/d87399782/htdocs/Internal/GENAddBoard.pl line 148.
For help, please send mail to the webmaster (webmaster@24sos.co.uk), giving this error message and the time and date of the error.
Ill try the path as /boards/general/ and see what I get>
Software error:
Unable to write open file. Reason: No such file or directory at /homepages/39/d87399782/htdocs/Internal/GENAddBoard.pl line 148.
For help, please send mail to the webmaster (webmaster@24sos.co.uk), giving this error message and the time and date of the error.
Its the same again - Ill try it with boards/general/ and see if that works>
Software error:
Unable to write open file. Reason: No such file or directory at /homepages/39/d87399782/htdocs/Internal/GENAddBoard.pl line 148.
For help, please send mail to the webmaster (webmaster@24sos.co.uk), giving this error message and the time and date of the error.
And thats the same aswell - I think Id better find out if its that part of the script that is causing the problem..line 148
1
2
3....
...
...148
Yep!
open (NEWMESSAGE, ">Boardsys/General/GEN$indexnumber.pl") or die "Unable to write open file. Reason: $!"; theres the problem
and heres the path from my ftp program to the dir where I need this file created.
/Internal/Boardsys/general/
I wonder if its case -sensitive???
Nope it doesnt make any difference
--------------------------------------------------------------------------
I am assuming that the > will create a file that doesnt exist or put content into the file if it does.
-----------------------------------------------------------------------------
O'REILLY Programming perl 3rd Edition Page 21
Book Quote =" open(SESAME, ">filename") # create file and write to it "
-----------------------------------------------------------------------------
Whats this?.........chuncks of hair and skin from my face!
For the sake of the 'O'Zone help, Im smoking like a chimney.
Thankszzzz
DAL
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|