Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Shell Scripting

Shell Scripting
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Aug 12, 2003, 08:12 AM
 
So for a newbie, what's involved in creating a shellscript? Is it just placing your command in a text file and adding a .sh extension?
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Aug 12, 2003, 08:25 AM
 
Originally posted by headbirth:
So for a newbie, what's involved in creating a shellscript? Is it just placing your command in a text file and adding a .sh extension?
Pretty much. A shell script is simply a file with executable permissions, some shell commands, and a "pound-bang" as the first line. The simplest shell script I can imagine is this:

Code:
#!/bin/sh echo "hello"
Put that in a file with UNIX line endings, do a chmod +x on the file, and you have a shell script. Where the "echo" line is, replace that with whatever shell commands you wish to execute.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Aug 14, 2003, 09:43 AM
 
looking to create this shellscript for stuffing and unstuffing operations on selected items in the Finder and then use something like platypus to make it an app and assign a key combination to launch it using KeyXing.

#!/bin/sh
cd __OBJ_PARENT_PATH__; /usr/local/bin/stuff -f sitx -n __OBJ_NAME__.sitx __OBJ_NAME__ -r 7

is this correct? how does one have it execute silently without opening Terminal windows?
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Aug 14, 2003, 12:52 PM
 
Originally posted by headbirth:
looking to create this shellscript for stuffing and unstuffing operations on selected items in the Finder and then use something like platypus to make it an app and assign a key combination to launch it using KeyXing.

#!/bin/sh
cd __OBJ_PARENT_PATH__; /usr/local/bin/stuff -f sitx -n __OBJ_NAME__.sitx __OBJ_NAME__ -r 7

is this correct? how does one have it execute silently without opening Terminal windows?
What are "__OBJ_PARENT_PATH__" and "__OBJ_NAME__" supposed to be? Is that something to do with platypus?

Something like this maybe:

Code:
#!/bin/sh item_to_stuff="$1" if [ "${item_to_stuff}" == "" ]; then echo "Usage: `basename $0` <item_to_stuff>" exit 1 fi cd `dirname ${item_to_stuff}` && /usr/local/bin/stuff -f sitx -n ${item_to_stuff}.sitx ${item_to_stuff} -r 7
I don't know anything about platypus, but from a strict shell perspective that would work.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:16 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2