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

cgi script works on Net Firms host, but local linux host can't read it 1

Status
Not open for further replies.

random260

Programmer
Mar 11, 2002
116
0
0
US
I have a cgi script that I wrote that works just ducky on the Net Firms web hosting site. I placed the script on our local server (a Linux box running Apache) and it acts like it can't even read it. I know cgi is working on the local server - I wrote a small "hello world" script USING THE TEXT EDITOR ON THE LINUX SERVER, and it worked fine. I wrote THE SAME EXACT "HELLO WORLD" SCRIPT on a Windows machine and FTPed it to the Linux box, and even the "hello world" script won't work (uploaded the same Windows "hello world" file to the Net Firms server, and it worked fine). I have tried writing the "hello world" script in Notepad, and in Wordpad (saving it in every text style I could, trying each one) and it just won't work. There must be some freaky codes or something that the windows text editor is putting in that the Linux box no-likey. I did notice that the difference betweent the "hello world" I wrote on the Windows box and the "hello world" I wrote on the Linux box is (when viewed with Notepad) is that the Windows one looks "normal", and the Linux one is all on one line, with the Carraige Returns being represented by little black squares (kinda like in Unicode text). Is there a Linux or Perl or Apache module somewhere that is not loaded on the Linux web server box or something? Or what IS the problem? I would apreciate any help.
Thanks.
 
Those black boxes are newlines, not carriage returns. On windows, a new line is represented by \r\n (carriage return and a newline) while on *nix it's represented as a \n only. You could try running the scripts through dos2unix before you try and execute them. dos2unix converts all \r\n's to \n's. So to convert test.cgi, you would type this at a command prompt:
dos2unix test.cgi
Though I really don't think that's the problem. Have you setup Apache to execute CGi scripts? //Daniel
 
Yes, Apache is set up for cgi, and cgi has been tested and works (as long as it is written on that linux box)
 
Did you try using dos2unix on your scripts? And who owns the scripts when you upload them? Do you chmod them correctly? //Daniel
 
OK, I had never heard of dos2unix, but I downloaded it and ran the "hello world" through it and uploaded it and guess what? The damn thing worked. I am going to try it on the main script now and see what it does - I'll keep ya posted. Thanks.
 
I should state that is was after the first reply (made by danielhozac) that I tried the dos2unix. I just completed the conversion for the main script, and it's a happy little cgi now. Thanks daniel. Even though you didn't think that was the problem, it was, and it was your dos2unix "tutorial" that fixed it. Our local Linux guru now bows to me, but I'll pass the bow on to you lol.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top