How do i get my script to run?

7,777 views
Skip to first unread message

bin

unread,
May 24, 2010, 10:46:37 AM5/24/10
to TextWrangler Talk
Im new to Mac and Im finding text wrangler so much harder than
notepad, how do I run my script every time I press the button I think
is run I get the below

This file doesn’t appear to contain a valid ‘shebang’ line
(application error code: 13304)

What am I doing how do I get the script to run?

Thanks Bin

--
You received this message because you are subscribed to the
"TextWrangler Talk" discussion group on Google Groups.
To post to this group, send email to textwr...@googlegroups.com
To unsubscribe from this group, send email to
textwrangler...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/textwrangler?hl=en
If you have a feature request or would like to report a problem,
please email "sup...@barebones.com" rather than posting to the group.

Thomas Fischer

unread,
May 24, 2010, 1:43:29 PM5/24/10
to textwr...@googlegroups.com
Hi Bin,

usually you would select the appropriate script in the status bar at the bottom of the page.
The TextWrangler will know which language to use.
The "shebang" line is the first line in the script that would tell other programs, e.g. a web server, which program to run, for Perl on my mac it looks like

#!/usr/bin/perl -w

And trust me, once you get a hang of it, you will not want to get back to notepad!

Cheers
Thomas

Thomas Fischer

unread,
Jan 18, 2013, 3:44:02 AM1/18/13
to textwr...@googlegroups.com
Hi Philip,

what do you want to do?

The mail below referred to running a script using TextWrangler, essentially passing it to the appropriate Unix program.
If you want to invoke a browser for you HTML code, you can use a little AppleScript script that opens your file in a browser (see below).
If you want colour coding, just select HTML in the pop-up menu in the status bar at the bottom of the window.

Best
Thomas

----- AppleScript, put into TextWrangler's Script Folder at ~/Library/Application Support/TextWrangler/Scripts/ ----

tell application "TextWrangler"
copy the file of document 1 to theFile
end tell
tell application "Safari"
open theFile
activate
end tell

-------------------

Am 18.01.2013 um 04:06 schrieb Philip Irvin:

I can't get it to work.  How do I get Text Wrangler work for html code?  What line would I put in the first line?

Eric Geiss

unread,
Mar 7, 2014, 12:15:32 PM3/7/14
to textwr...@googlegroups.com

Phillip,

I am a computer science major and not an expert by any means but this should help.  I was having the same problem when switching from notepad++ on pc.   Instead of clicking run like you would on notepad++, just save the file as a .html and then open whatever browser (i.e. Safari or Firefox) you want the code to run on.  Select file from the browser's menu bar and click open file, then select the .html file you saved and click open and if your code is correct your work should appear in your browser window.  To make sure there is no errors in your code i recommend using the html validator at http://validator.w3.org.  Like all html code your first line should be 
<!DOCTYPE html> followed by
<html>
Hope this helps.

-Eric

Tami Cook

unread,
May 5, 2016, 2:41:15 PM5/5/16
to TextWrangler Talk
Hi Bin, just wondering if you found a fix, I am having a similar problem. I am trying to write a script ( I have tried TextWrangler and Apple script editor) and the script will stop on errors, I would like the script to continue running even if it comes across an error. I am trying to clean up some student computers at the end of the year. The script is below: If it runs into a folder Ex: movies without anything in it it will just stop. Do you know how to make it continue going through the script?
ell application "Terminal"
    do shell script "rm -r ~/Desktop/*"
    delay 1 --pause for a sec
    do shell script "rm -r ~/Documents/*"
    delay 1 --pause for a sec
    do shell script "rm -r ~/Pictures/*"
    delay 1 --pause for a sec
    do shell script "rm -r ~/Movies/*"
    delay 1 --pause for a sec
    do shell script "rm -r ~/Music/*"
    delay 1 --pause for a sec
    do shell script "rm -r ~/Downloads/*"
    delay 1 --pause for a sec
    tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Solid Colors/Solid Aqua Dark Blue.png"

end tell

Patrick Woolsey

unread,
May 18, 2016, 11:25:40 AM5/18/16
to textwr...@googlegroups.com
In hope this info may still be of help:

For reference, the stop-on-error behavior you're seeing is
intrinsic to AppleScript, and not related to either TextWrangler
or the prior poster's question. :-)

Thus, in order to prevent your script from stopping on errors,
you'll need to wrap each command within a 'try' block as
detailed here:

try Statements | AppleScript Language Guide
<https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_control_statements.html#//apple_ref/doc/uid/TP40000983-CH6g-128973>

so your script would then look something like this:

====
tell application "Terminal"
try
do shell script "rm -r ~/Desktop/*"
delay 1 --pause for a sec
end try
try
do shell script "rm -r ~/Documents/*"
delay 1 --pause for a sec
end try
[ ... etc ... ]
====

[PS: Since you just want your script to keep running and don't
need to perform any alternate actions if an error occurs, you
can omit the optional 'on error' statements.]


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com/>
Reply all
Reply to author
Forward
0 new messages