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
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status: Offline
Reply With Quote
Dec 23, 2002, 01:49 AM
 
Hi,
I wanted to make a little script so that when I type "seti" into the command line, it runs setiathome in a pre-specified folder. At the moment, I have in my .cshrc file:

alias set "cd ~/.setiathome && setiathome"

But this doesn't quite work. It still just runs setiathome in my home directory. Could somebody show me how to go about doing this? I'd like to learn as much as possible too. Thanks a bunch!

Gabe
     
Junior Member
Join Date: Nov 2000
Location: Kalamazoo, Michigan, USA
Status: Offline
Reply With Quote
Dec 24, 2002, 07:58 PM
 
Originally posted by Zimwy:
<snip>
alias set "cd ~/.setiathome && setiathome"

But this doesn't quite work...
Perhaps you might want to try:

alias set "cd ~/.setiathome && ./setiathome"

If the present working diretory (here, setiathome) isn't in your path, it won't be able to run the program. There are good reasons for not putting the present working directory in your path, try searching google if you're curious about the debate.
Charles
     
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Dec 24, 2002, 08:33 PM
 
Two thoughts:

1) your example shows you aliasing 'set'. 'set' is a built-in shell command and it's not advisable to use this as an alias name.

2) create a shell script:

Code:
#! /bin/sh cd ~/.setiathome ./setiathome
and save it as /usr/bin/seti, then chmod a+x /usr/bin/seti and you're all set.
Gods don't kill people - people with Gods kill people.
     
Zimwy  (op)
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status: Offline
Reply With Quote
Dec 24, 2002, 08:40 PM
 
Hey,
I actualled figured out the alias. I was just being stupid. I'd love to learn more about shell scripting though. Is there any place you guys can turn me to to learn? Thanks!

Gabe
     
Junior Member
Join Date: Nov 2000
Location: Kalamazoo, Michigan, USA
Status: Offline
Reply With Quote
Dec 25, 2002, 02:20 AM
 
Originally posted by Zimwy:
I'd love to learn more about shell scripting though. Is there any place you guys can turn me to to learn?
D&aelig;mon News, an online and print magazine, had a great introduction to the C shell last year. It starts off with the basics and discusses all sorts of nifty things you can do with csh and tcsh.
Part 1 - Part 2 - Part 3

Also, the original paper written by Bill Joy, author of the C shell, is available on the internet:
http://docs.freebsd.org/44doc/usd/04.csh/paper.html
(or, as a PDF with full glossary and appendix at http://docs.freebsd.org/44doc/usd/04.csh/paper.pdf)

I guess those are the two best resources I can think of off the top of my head on the internet. I hear O'Reilly's book Using csh & tcsh is also supposed to be a great reference.
Charles
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Dec 29, 2002, 12:59 AM
 
As many will tell you, it is generally considered a bit poor to use the c shell. This is because it isn't terribly consistent across platforms.

I typically use sh for simple scripting and if it is more complex use either TCL or Python. A lot of people swear by Perl as well.
     
   
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 12:06 PM.
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