The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > OS X (Apple)
Google UNIX.COM


OS X (Apple) OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running a script without a terminal session jjinno Shell Programming and Scripting 3 10-02-2007 10:50 PM
run script through terminal sadiquep Linux 4 05-24-2007 04:49 AM
Script to launch terminal window? omerta SUN Solaris 5 06-30-2005 02:48 PM
Run the start script from the terminal? Newbie Time! waking_bear UNIX for Dummies Questions & Answers 4 03-04-2004 03:09 PM
connecting to unix through hyper terminal - as a dumb terminal michelle UNIX for Advanced & Expert Users 2 11-05-2001 11:32 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-01-2006
Registered User
 

Join Date: Aug 2006
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Question Terminal script

I'd like to write a script that will run when I log into OS X, which will do the following:

1) Launch Terminal
2) Immediately close the window that Terminal creates when it opens.
3) Preferably, keep Terminal hidden while all this is happening, so all I see is the Terminal icon bouncing in the dock as the program launches.

Any advice appreciated

PS: I'd prefer the script to be a .sh or a .c file (to compile), as those are the only two languages I have some experience in at the moment. Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-01-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 355
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Why not to do this when you enter runlevel 5?
Reply With Quote
  #3 (permalink)  
Old 09-01-2006
Registered User
 

Join Date: Aug 2006
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by Hitori
Why not to do this when you enter runlevel 5?
Sorry, that's way beyond my experience right now. I don't even properly understand what you mean! Can you explain?
Reply With Quote
  #4 (permalink)  
Old 09-01-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 355
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
A runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init process for each of these runlevels are defined in the /etc/inittab file. Runlevels 0, 1, and 6 are reserved. Other runlevels are dependent on how your particular distribution has defined them, and they vary significantly between distributions.

Most users run X from runlevels 3 or 5 (for linux?). Runlevel 3 places your system in multi-user mode with full networking capabilities. The machine will boot to a text-based login prompt with all necessary preconfigured services started. Most servers are run in runlevel 3, as X is not necessary to provide any services utilized by most users. Runlevel 5 is similar to 3, except that it automatically starts X and provides a graphical login screen. Many workstation users prefer this method, because it never forces them to see a command prompt.

You can add commands that must be executed in appropriate runlevel in some file/under some directory (e.g. /etc/rc.d/rc5.d)
Reply With Quote
  #5 (permalink)  
Old 09-01-2006
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,439
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Here is what happens when OS X boots:

http://www.kernelthread.com/mac/osx/arch_startup.html
Reply With Quote
  #6 (permalink)  
Old 09-08-2006
Registered User
 

Join Date: Sep 2002
Location: San Fran
Posts: 105
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
It would be helpful to know why this operation is important because there may be a better way to accomplish the "why" than you might realize.
I can't image a use for having Terminal launch at startup without a window. Not that there isn't one, but I just can't imagine it.

AppleScript can be used to hide a window, but the application first has to create the window (which displays on creation), then hide it immediately. The window is thus only visible for a split second.

You can send applescript code from shell scripts using the osascript command (man osascript).

You can examine Terminal's applescript functionality from within Script Editor.app by selecting "Open Dictionary..." from the Script Editor "File" menu, then navigating to Terminal.app.

Otherwise, I don't know if this is possible from the command line.
Reply With Quote
  #7 (permalink)  
Old 09-15-2006
Registered User
 

Join Date: Sep 2006
Posts: 11
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
login hook ?

Maybe a login hook could do the trick?

sudo defaults write com.apple.loginwindow LoginHook /path/to/script

(For more information see http://www.bombich.com/mactips/loginhooks.html and http://docs.info.apple.com/article.html?artnum=301446 )

Using AppleScript you could try something like this:
osascript -e 'tell application "Terminal" to launch' -e 'tell application "System Events" to set visible of some item of ( get processes whose name = "Terminal" ) to false'

Btw, you can 'reset' Terminal.app by deleting the Terminal.plist file:
rm "$HOME/Library/Preferences/com.apple.Terminal.plist"
Reply With Quote
Google UNIX.COM
Reply

Tags
linux

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix curses.h cut command in unix daemon process find grep find mtime find null character in a unix file from ip can we get machine name +unix glance unix grep multiple lines grep or grep recursive how to redirect console logs in unix inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude tar extract to folder unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute while loop within while loop shell script


All times are GMT -7. The time now is 11:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101