Shell Broken ?

A

A.I. BOT

Guest
I recently switched from Linux to Mac. I was making a shell script. I loaded it up on my browser and it gave me a 500 error. I checked my logs, it said Premature end of script headers. This script did work on my Linux.

So I made a new little script with something as simple as:
Code:
#!/bin/sh
echo Content-Type: text/html
echo
echo Hello!

It failed. Same header error. But the same script works on my Linux. So I ran the script in the Terminal. The output: :/

Code:
$ sh test.sh
echoent-Type: text/html

Why does it look like that :/ On my Linux I get:
Code:
$ sh test.sh
Content-Type: text/html

Hello!

Any ideas ?

Thanks.
 
Joined
Aug 4, 2006
Messages
47
Reaction score
1
Points
8
Location
Windsor, Ontario (Canada)
Your Mac's Specs
2.16 Ghz MacbookPro, 1GB RAM, Radeon X1600, 100GB Hard Disk
I don't know what is wrong, but I can confirm that something is wrong.
Code:
adrian-petrescus-computer:~ adrianpetrescu$ vim test.sh
adrian-petrescus-computer:~ adrianpetrescu$ chmod a+x test.sh 
adrian-petrescus-computer:~ adrianpetrescu$ ./test.sh 
Content-Type: text/html

Hello!
The same script works fine for me. :( Sorry...
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
I don't know about everyone else, but this is the way I would write it.

#!/bin/sh
echo "Content-Type: text/html\n"
echo "Hello!"
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top