Terminal script | Unix Linux Forums | OS X (Apple)

  Go Back    


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

Terminal script

OS X (Apple)


Tags
linux, linux commands, shell script, shell scripting, unix scripting, unix scripting basics

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-01-2006
black-eyed-dog black-eyed-dog is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 1 September 2006, 2:16 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old 09-01-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
kharkovpromenade.com.ua
 
Join Date: Jun 2006
Last Activity: 10 December 2011, 9:33 AM EST
Posts: 360
Thanks: 0
Thanked 9 Times in 8 Posts
Why not to do this when you enter runlevel 5?
Sponsored Links
    #3  
Old 09-01-2006
black-eyed-dog black-eyed-dog is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 1 September 2006, 2:16 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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?
    #4  
Old 09-01-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
kharkovpromenade.com.ua
 
Join Date: Jun 2006
Last Activity: 10 December 2011, 9:33 AM EST
Posts: 360
Thanks: 0
Thanked 9 Times in 8 Posts
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)
Sponsored Links
    #5  
Old 09-01-2006
reborg's Avatar
reborg reborg is offline Forum Advisor  
Administrator Emeritus
 
Join Date: Mar 2005
Last Activity: 29 March 2012, 7:00 PM EDT
Location: Ireland
Posts: 4,464
Thanks: 0
Thanked 10 Times in 10 Posts
Here is what happens when OS X boots:

http://www.kernelthread.com/mac/osx/arch_startup.html
Sponsored Links
    #6  
Old 09-08-2006
[MA]Flying_Meat [MA]Flying_Meat is offline
Registered User
 
Join Date: Sep 2002
Last Activity: 12 February 2014, 2:48 PM EST
Location: San Fran
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
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.
Sponsored Links
    #7  
Old 09-15-2006
verno verno is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 29 November 2008, 4:55 AM EST
Posts: 14
Thanks: 0
Thanked 1 Time in 1 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"
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Terminal Command into script ab52 OS X (Apple) 2 08-16-2011 11:31 AM
Script to run a command in a new terminal sojo1024 UNIX for Dummies Questions & Answers 1 06-14-2011 03:33 PM
terminal script stops after script command :(. drdread OS X (Apple) 6 02-04-2009 12:37 PM
run script through terminal sadiquep Linux 5 09-24-2008 07:44 AM
connecting to unix through hyper terminal - as a dumb terminal michelle UNIX for Advanced & Expert Users 2 11-05-2001 02:32 PM



All times are GMT -4. The time now is 09:37 AM.