New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Help with the bash...alias/script...?

Post Reply New Thread Subscribe

Thread Tools

Antares's Avatar
Member Since: Oct 19, 2009
Posts: 17
Antares is on a distinguished road
Mac Specs: MacBook Pro 13" 2.53GHz 4GB OSX 10.6

Antares is offline
Hey everyone

I'm new to Mac OS, just switched from Ubuntu and sometimes its quite hard to get used to different stuff...

So, I searched the Internet for over an hour, but nothing could solve my problem. You will see it is quite simple (at least it was in ubuntu)

All I want to do is following:

To launch a particular program, I have to start X11 (xgterm), change directory and execute a command.

so basically its:

cd /iraf
xgterm -sb -geometry 80x24 -title "Image Reduction and Analysis Facility (IRAF)" -bg "black" -fg "orange" -bd "white" -cr "grey" -e "ecl"

and I don't want to type this every time I have to use the program. My question is: Can I create an alias, or write a script, so that I just have to type one simple command to execute those above in the bash?

Another thing is: In ubuntu I could launch all apps by typing their names (whatever was in /usr/local/bin). How do I create such a file, which enables me to launch a specific app from the terminal...?

I hope you can help me
QUOTE Thanks

Member Since: May 02, 2009
Posts: 480
wmprice1240 has a spectacular aura about
Mac Specs: MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB

wmprice1240 is offline
The concepts are the same on OSX so there should not be any real differences in what you are trying to do.

There is obviously no xgterm in OSX, it is simply xterm. Did you install X11 on your Mac? You didn't state the version of OSX you are using.In 10.6 (Snow Leopard) you would have the option to install this during installation. In 10.5 X11 will be on your install disks.

From what I am reading it sounds like you need to update your path to include the directories you want so you can simply type the name in the terminal. You can do this in either a .bash_login or .bashrc file. Example:


export PATH

Note, there are no '' characters around the dollar sign, these were added for escaping.

My question is: Can I create an alias, or write a script, so that I just have to type one simple command to execute those above in the bash?
Scripting bash should work the same as on Linux so any scripts you write for those platforms should port easily to OSX. For the most part, bash is bash independent of platform on which you are running. Of course certain executables, variables etc may be different, but these can be easily resolved by pointing to the correct location.
QUOTE Thanks

nabl's Avatar
Member Since: Dec 13, 2007
Location: United States of America
Posts: 256
nabl has a spectacular aura about
Mac Specs: 2.1GHz MacBook with 4GB RAM, Mac OS X 10.6, iLife and iWork 09

nabl is offline
For your first question, all you'd need to do is add those commands to a script and then add it to a directory in your PATH to run them with a single command. [Edit: I forgot to mention that you'll probably have to chmod +x the script to run it directly.] In addition, if you want to run the script by opening it from the Finder or even from the Dock, write it as you would a .sh file and then save it as a .command file. If it isn't already, associate it with and then you can simply open it in the Finder or from the Dock to run the script. You can change whether the Terminal window stays open after it finished in the Shell tab of the Settings pane of Terminal's preferences.

As for your second question, just use the open command. For example, open -a Mail will open Mail.
QUOTE Thanks

Post Reply New Thread Subscribe

« how to open Midnight Commander(MC) menu? | Objective C Books that don't need C knowledge »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Mouse copy & paste (Linux bash style) in OS X ? kkempter OS X - Operating System 3 03-28-2009 09:55 AM
Ruby with MacPorts in bash help? whiteunibrow OS X - Development and Darwin 0 01-29-2009 09:04 PM
Launching applescript from bash samimk120 OS X - Development and Darwin 1 09-08-2008 12:35 AM
Auto-Logging BASH session quietly danjmwalker OS X - Development and Darwin 0 10-04-2007 02:19 PM
Bash Script ftjogoh Apple Notebooks 1 11-04-2004 01:14 PM

All times are GMT -4. The time now is 11:15 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?