Results 1 to 3 of 3
  1. #1

    Antares's Avatar
    Member Since
    Oct 19, 2009
    MacBook Pro 13" 2.53GHz 4GB OSX 10.6
    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

  2. #2

    Member Since
    May 02, 2009
    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:


    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.

  3. #3

    nabl's Avatar
    Member Since
    Dec 13, 2007
    United States of America
    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 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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. rSync commandline bash script
    By scar1 in forum macOS - Operating System
    Replies: 2
    Last Post: 03-19-2015, 09:49 PM
  2. Run bash script via button in interface builder?
    By Bwoe in forum macOS - Development and Darwin
    Replies: 5
    Last Post: 03-23-2011, 08:58 PM
  3. Newbie help with bash script to search and replace a filename
    By gilc in forum macOS - Development and Darwin
    Replies: 5
    Last Post: 02-25-2010, 04:23 PM
  4. How Do I Get Finder to Execute a Bash Script?
    By mac57 in forum macOS - Development and Darwin
    Replies: 7
    Last Post: 06-08-2006, 03:01 PM
  5. Bash Script
    By ftjogoh in forum Apple Notebooks
    Replies: 1
    Last Post: 11-04-2004, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts