Go Back  Mac-Forums.com  > Software > OS X - Darwin and Development > Help with the bash...alias/script...?

Reply
 
LinkBack Thread Tools
Old 10-26-2009, 06:39 AM   #1 (permalink)
Antares

 
Member Since: Oct 19, 2009
Posts: 2
Antares is on a distinguished road
Help with the bash...alias/script...?

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
cheers
Antares is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 10-26-2009, 11:31 AM   #2 (permalink)
wmprice1240
Banned
 
Member Since: May 03, 2009
Posts: 481
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
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:

PATH=/usr/local/bin:'$'PATH:

export PATH

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

Quote:
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.
wmprice1240 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Old 10-26-2009, 01:32 PM   #3 (permalink)
nabl

 
nabl's Avatar
 
Member Since: Dec 13, 2007
Location: United States of America
Posts: 110
nabl will become famous soon enough
Mac Specs: 2.1GHz MacBook with 4GB RAM, Mac OS X 10.6, iLife and iWork ‘09
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 Terminal.app 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.

Last edited by nabl; 10-26-2009 at 01:41 PM.
nabl is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Stumble this post
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On

Forum Jump

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

 
 
 
     
Home Calendar Get New
     

Copyright ©2001-2009 Mac-Forums.com. All Rights Reserved. A division of iNET Interactive.

Other iNET Interactive Sites: Web Hosting Talk | Swish Talk | Hosting Catalog.com| Dev Papers| Deleted Domains| Hot Scripts

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