 |
 |
Shell Scripting
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |