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

Similar Threads
thread Thread Starter Forum Replies Last Post
How to create an applescript for multiple dd terminal commands in sequence ? AlbertoBC Mac Programming 2 Feb 2, 2014 01:30 PM
How to create Terminal Shortcut? v2club OS X 10.8 Mountain Lion 9 Aug 17, 2013 01:56 PM
Geektool: Your Geektool scripts (II) brenm666 UI Customization 10 Dec 5, 2012 10:55 AM
Scripts Folder woodaman09 OS X 2 Jul 10, 2012 11:03 AM
Scripts in Finder radek42 Mac Applications and Mac App Store 4 Jun 27, 2012 05:19 PM

Forum Jump

All times are GMT -5. The time now is 03:09 PM.

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

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