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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem writing file: header or hidden character issue?

Status
Not open for further replies.

craigrichards

Programmer
Feb 22, 2000
6
US
I wrote a Perl script that mimics almost all FTP client functions - however...

The upload function works great for text and image file uploads and writes them just fine as long as the text file is plain text or HTML.

If I upload a script, it won't execute (yes, permissions are changed to 755 or 777). If I use my FTP client to download the script and reupload - with no modifications whatsoever - it executes perfectly.

I suspect it's an issue with how my script utility is writing the file. Is there a mode I can switch to? Are there hidden characters generated by the browser form field that need to be stripped? Is there a "header" line (or some other string) that needs to precede the while print loop?

Server: Linux/Apache/Perl5
Browser: IE5

Here's the code:

open (FILE,">$path$filename");
binmode FILE; # for writing to Windows
while (my $byteorder=read($newfile, my $buffer, 1024)) {
$size += $byteorder;
print FILE $buffer;
}
close (FILE);


I figure some programmer much more clever than I has encountered this issue before and resolved it - thanks in advance for your help.
 
First guess - ...... if you are writing from a Win Platform and uploading your script to a UNIX platform, you need to convert the line endings from '\n\r' to '\n'. Several popular editors will do that on the Win side or some FTP packages will handle it on the fly, or you can use 'dos2unix' on the server. Anyway, if the script runs on the PC, is uploaded, execute bits are set, and it won't run on the UNIX server, I bet line endings are your problem.

good luck
 
goBoating:
I am amazed at how simple the solution was. This was an issue I'd encountered a couple years ago and had forgotten - until your gentle and informative reminder!

You have my gratitude and the thanks of thousands of users around the world who use AdminPro. I've just released an upgrade that allows users complete FTP-like file management from their browsers (including script uploading!) as well as CGI syntax checking with a click of a mouse. I encourage you to download it and try it out at
I'd be interested in your thoughts and any suggestions for improvement you may have.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top