Terminal script


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) Terminal script
# 1  
Old 09-01-2006
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 Smilie

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.
# 2  
Old 09-01-2006
Why not to do this when you enter runlevel 5?
# 3  
Old 09-01-2006
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
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)
# 5  
Old 09-01-2006
Here is what happens when OS X boots:

http://www.kernelthread.com/mac/osx/arch_startup.html
# 6  
Old 09-08-2006
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.
Smilie
# 7  
Old 09-15-2006
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"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

2. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies

3. Shell Programming and Scripting

Run script in new terminal

Hi Guys, I have a script that runs certain simulations in batch mode. I need to schedule some simulations to run over night. For each simulation to complete it should be run in separate terminal. My script is as follows sh run_test.sh <arg1> <arg2> <arg3> ... I need to launch this... (5 Replies)
Discussion started by: aelhosiny
5 Replies

4. OS X (Apple)

Terminal Command into script

Hi All I have this script that checks to see if ntp is enabled on a machine launchctl load -w /System/Library/LaunchDaemons/org.ntp.ntpd.plist It retuns org.ntp.ntpd: Already loaded if it is loaded, is there a way to script it so that if it is loaded it does not say anything but... (2 Replies)
Discussion started by: ab52
2 Replies

5. UNIX for Dummies Questions & Answers

Gnuplot wxt terminal vs x11 terminal

Hi, I installed ubuntu recently on my pc. And I installed gnuplot as well. When I first started working with gnuplot it was working . I did a plot and when I wanted to fit my data something happened and not the default terminal of gnuplot is xwt! I changed it to: set terminal x11, but it... (0 Replies)
Discussion started by: cosmologist
0 Replies

6. OS X (Apple)

terminal script stops after script command :(.

Hello, i am trying to write a script for terminal for my mac that i may drag into the terminal and will excute the following command: script -akq Desktop/TerminalLogin/Cisco1Bob.txt telnet x.x.x.x the problem is that when i drag the text file to the terminal window the script stops after... (6 Replies)
Discussion started by: drdread
6 Replies

7. Shell Programming and Scripting

running terminal with script

suppose we have a file ab 81 and another file exec < $1 while read line do ssh root@172.16.1.$line done while running the command sh file.sh ab output display as shown Pseudo-terminal will not be allocated because stdin is not a terminal. root@172.16.1.81's password: after... (3 Replies)
Discussion started by: cdfd123
3 Replies

8. Linux

run script through terminal

for all friends i am using linux enterprise 4. i installed oracle 10g in user name oracle.at the end of install i got a pop up window saying that u should run the following scripts(root.sh,orainstRoot.sh) in terminal from root account(cui) without log out oracle account . how i can run these... (5 Replies)
Discussion started by: sadiquep
5 Replies

9. UNIX for Advanced & Expert Users

Pseudo-terminal will not be allocated because stdin is not a terminal.

I am trying to automate a SSH login using Keys using the following command ssh -i id_rsa usernamw@ipaddr. I am successful in doing this and i am getting the Warning Screen and I logon successfully. but when I am executing the command tail -1cf put.dat | ssh -i id_rsa username@ipaddr > get.dat ... (1 Reply)
Discussion started by: Shivdatta
1 Replies

10. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies
Login or Register to Ask a Question