Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 24, 2008, 03:24 PM   #1
Spanky Deluxe
macrumors 601
 
Spanky Deluxe's Avatar
 
Join Date: Mar 2005
Location: London, UK
How do I create terminal scripts? [Merged]

I know this is a particular basic question, but how do I create terminal scripts that I can just type in to a terminal window and they'll just execute a few commands? Basically the equivalent to a DOS batch file.

I know its ridiculously easy but I don't know how to do it!
__________________
"No, I'm from Iowa, I only work in outer space."

Last edited by Blue Velvet; Jul 22, 2008 at 04:58 PM. Reason: Added [Merged] to title
Spanky Deluxe is offline   0 Reply With Quote
Old Apr 24, 2008, 05:14 PM   #2
MacsRgr8
macrumors 604
 
MacsRgr8's Avatar
 
Join Date: Sep 2002
Location: The Netherlands
In the Terminal, create a new file: (ignore ">")
> touch test <ENTER>

Edit that file:
> pico test <ENTER>

Start off by showing it is a shell script:
> #!/bin/sh
> "type_your_command_here" (i.e. > say hello)

Save and exit:
CTRL-O <ENTER>, CTRL-X <ENTER>

Now, make it executable:
> chmod 755 test <ENTER>

Test it:
> ./test <ENTER> (if you typed "say hello", your Mac would really say "Hello" to you.

In the Finder you can put ".command" at the end of "test".
If you do that, your script will open the Terminal and run it.

Have fun!
__________________
Steve Jobs. 1955 - 2011. My Hero.
MacsRgr8 is offline   2 Reply With Quote
Old Apr 24, 2008, 05:27 PM   #3
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by Spanky Deluxe View Post
I know this is a particular basic question, but how do I create terminal scripts that I can just type in to a terminal window and they'll just execute a few commands? Basically the equivalent to a DOS batch file.

I know its ridiculously easy but I don't know how to do it!
Read up on Bash scripting, another alternative if you want a more Apple style scripting language is to use Applescript.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Jul 22, 2008, 03:31 PM   #4
Spanky Deluxe
Thread Starter
macrumors 601
 
Spanky Deluxe's Avatar
 
Join Date: Mar 2005
Location: London, UK
Stupid question: How can I create terminal scripts?

This is probably a really basic thing for anyone that uses them but how do you create terminal scripts? Basically the equivalent to the old fashioned MS DOS batch file.
__________________
"No, I'm from Iowa, I only work in outer space."
Spanky Deluxe is offline   0 Reply With Quote
Old Jul 22, 2008, 03:32 PM   #5
janey
macrumors 603
 
janey's Avatar
 
Join Date: Dec 2002
Location: sunny los angeles
A text editor?

Some basic knowledge of bash?
__________________
iPad | 15" MacBook Pro | black (iPhone 3GS|MacBook) | Mac mini server
moof!

janey is offline   0 Reply With Quote
Old Jul 22, 2008, 03:34 PM   #6
GGJstudios
macrumors Westmere
 
Join Date: May 2008
Did you try searching the forums? There appears to be several threads that might help.
GGJstudios is offline   0 Reply With Quote
Old Jul 22, 2008, 03:40 PM   #7
Spanky Deluxe
Thread Starter
macrumors 601
 
Spanky Deluxe's Avatar
 
Join Date: Mar 2005
Location: London, UK
Quote:
Originally Posted by ggjstudios View Post
Did you try searching the forums? There appears to be several threads that might help.
Cheers. Oh dear, that's embarrassing, I've asked this before! Extra proof at how bad my memory is!! :$
__________________
"No, I'm from Iowa, I only work in outer space."
Spanky Deluxe is offline   0 Reply With Quote
Old Feb 4, 2010, 04:14 AM   #8
nntn61
macrumors newbie
 
Join Date: Feb 2010
...

Last edited by nntn61; Feb 4, 2010 at 04:20 AM. Reason: Stupid question, figured it out....
nntn61 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How do you create a bootable external drive? gangof4 Mac Peripherals 2 Jul 24, 2011 04:54 PM
How do I create an Album Thumbnail for my created music? jayeskreezy Digital Audio 3 Jan 5, 2009 07:39 PM
How Do I Use this script? GabeJ iPhone/iPad Programming 1 Sep 28, 2008 01:00 PM
How do I run a script at logout? lancestraz OS X 2 Jun 19, 2007 05:58 AM
iTunes & Automator... How Do I Create a Script? jaw04005 OS X 1 May 11, 2005 04:34 PM


All times are GMT -5. The time now is 08:37 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC