TextWrangler on Mac

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Delalyra
Posts: 1812
Joined: Fri Aug 31, 2007 12:39 am UTC
Location: Western Mass
Contact:

TextWrangler on Mac

Postby Delalyra » Sun Sep 16, 2007 11:16 pm UTC

So some people here reccomended TextWrangler as a free C++ compiler on a Mac, so I downloaded it, and it's cool. One question, though: I wrote a simple "hello world" program, and it keeps giving me the following error:
This file doesn’t appear to contain a valid ‘shebang’ line (application error code: 13304)

Did I miss a setting or something? Thanks in advance.


Edit: erm, maybe this is in the wrong forum. If it should be in Help Desk or somewhere, feel free to move it.

Rysto
Posts: 1459
Joined: Wed Mar 21, 2007 4:07 am UTC

Postby Rysto » Sun Sep 16, 2007 11:31 pm UTC

How did you compile your file? The error message indicates that the file that you're trying to run is not an executable file.

User avatar
Delalyra
Posts: 1812
Joined: Fri Aug 31, 2007 12:39 am UTC
Location: Western Mass
Contact:

Postby Delalyra » Sun Sep 16, 2007 11:52 pm UTC

I...don't know, I guess I didn't, heh. I found a button that said "run," clicked it, and got said error. I just went though TextWrangler's help files and didn't find anything about compiling, nor did I find anything in the menus.

I suppose my actual question is, then: how do I compile a file?

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Postby mrkite » Mon Sep 17, 2007 2:08 am UTC

What's the extension? the shebang line is for scripts.. like perl or bash or python. Not for executables.

So why does textwrangler thing you're running a script?

EvanED
Posts: 4321
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Postby EvanED » Mon Sep 17, 2007 2:13 am UTC

TextWrangler looks to just be a text editor, not including a C++ compiler. I could be wrong, but that's what the wikipedia page makes it out to be.

User avatar
Nexuapex
Posts: 22
Joined: Thu Sep 06, 2007 3:01 am UTC
Location: Northwest Iowa
Contact:

Postby Nexuapex » Mon Sep 17, 2007 2:53 am UTC

TextWrangler is, indeed, simply a text editor. You'd have to use the command line to compile and run your program.
“It’s my estimation that every man ever got a statue made of him was one kind of a son of a bitch or another.”

Rysto
Posts: 1459
Joined: Wed Mar 21, 2007 4:07 am UTC

Postby Rysto » Mon Sep 17, 2007 3:16 am UTC

mrkite wrote:What's the extension? the shebang line is for scripts.. like perl or bash or python. Not for executables.

So why does textwrangler thing you're running a script?

The way that Unix works when you try to execute a file, is that it first sees if its a type of executable file that it recognizes(like a.out or ELF format), and if that fails, it tries to execute it as a script and looks for the shebang. It's probably trying to execute the source file as a script.

User avatar
xyzzy
Meta-Titled
Posts: 263
Joined: Sun Mar 18, 2007 10:02 pm UTC
Location: Colossal Cave
Contact:

Postby xyzzy » Thu Sep 20, 2007 4:34 pm UTC

And as C is not a scripting language, the Run button fails, as there is no shebang line. Compile the file through the command line, chmod it executable if necessary, and run it with ./filename
"Wile E. Coyote was a theoretical mathematician." - Leliel
"Modern life can be so boring without elements of the bizarre or the fantastical. Hence, we have steampunk." - Me

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Postby mrkite » Thu Sep 20, 2007 8:15 pm UTC

Just to see if I could:

Code: Select all

#!/bin/sh
/usr/bin/gcc -xc - <<EVILEOF

#include <stdio.h>

int main()
{
        printf("this is so wrong\n");
}

EVILEOF
./a.out


Dump that whole thing in a file, and it'll run both from the shell and from textwrangler.

EvanED
Posts: 4321
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Postby EvanED » Thu Sep 20, 2007 8:30 pm UTC

mrkite wrote:Just to see if I could:

Code: Select all

#!/bin/sh
/usr/bin/gcc -xc - <<EVILEOF

#include <stdio.h>

int main()
{
        printf("this is so wrong\n");
}

EVILEOF
./a.out


Dump that whole thing in a file, and it'll run both from the shell and from textwrangler.

Beautiful.

And by "beautiful" I mean "please shoot me now" ;-)

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Postby mrkite » Fri Sep 21, 2007 2:30 am UTC

EvanED wrote:Beautiful.

And by "beautiful" I mean "please shoot me now" ;-)


Hehe, while I was writing that I was having flashbacks to old Unix "shar" files from back in the day.

theviscount
Posts: 1
Joined: Sun Dec 11, 2016 2:37 am UTC

Re: TextWrangler on Mac

Postby theviscount » Sun Dec 11, 2016 2:40 am UTC

Hey MR.KITE,

I just want to say, it is 2016. Ten years later since you have written this post, and I think that it is amazing that the advice that you gave that other person still works. Just wanted to say THANKS. It still works.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 13 guests