|
|
#1 |
|
Triple-A Player
Join Date: Jan 2002
Location: CT
Posts: 71
|
Simple startup script for OSX?
Hi everyone,
I have a quick question (and hopefully easy). I'm trying to learn unix, but and there certain things that i'm still not getting. I've tried a number of ways with no success. Here's the problem. I want a simple script that will run a command line app as the computer starts up. (And if you want to know its the command line version of setiathome). Basically I want to run the app every time I log in (I don't want to use the screen saver version). Thanks for any help that you can provide. --WH
__________________
Finally, the power of UNIX! Ti Book 867 G4 Dual 1 Ghz G4 Dual 450 B&W G3 450 (with G4 1Ghz Upgrade) Beige G3 300 Last edited by War_Hawk; 01-29-2002 at 11:31 AM. |
|
|
|
|
|
#2 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
hawk,
you can hook a reference to the setiathome app in your login startup sequence, which you'll need to tell us about. do you use the vanilla tcsh install on OSX? or bash? or some other shell? for starters, examine the README and the scripts here... Code:
% ll /usr/share/init/tcsh/ total 40k -rw-r--r-- 1 root wheel 952 Sep 2 20:35 README -rw-r--r-- 1 root wheel 892 Sep 2 20:35 aliases -rw-r--r-- 1 root wheel 9.4k Sep 2 20:35 completions -rw-r--r-- 1 root wheel 433 Sep 2 20:35 environment -rw-r--r-- 1 root wheel 701 Sep 2 20:35 login -rw-r--r-- 1 root wheel 395 Sep 2 20:35 logout -rw-r--r-- 1 root wheel 1.9k Sep 2 20:35 rc -rw-r--r-- 1 root wheel 2.3k Sep 2 20:35 tcsh.defaults |
|
|
|
|
|
#3 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
/Library/StartupItems/
Take a look at /Library/StartupItems/. You should see a few startup items which you can open in pico, emacs, bbedit. It is pretty trivial to understand how they work. If /Library/StartupItems/ does not exist, look at /System//Library/StartupItems/. Don't put anything in /System/Library/StartupItems/: it is for system use only. Put you stuff in /Library/StartupItems/.
You create a directory with a file having the same name. This is the program. You also provide a .plist file with various information regarding what it provides, what it needs, etc... |
|
|
|
|
|
#4 |
|
Triple-A Player
Join Date: Jan 2002
Location: CT
Posts: 71
|
I correction i want seti to run every time i log in (prior i wrote that didn't want.. sorry).
mervTormel, yes a start up sequence is exactly what i'm looking for. Yes i am using the tcsh that came with OS X.1.2. And I took a look at [macninename:share/init/tcsh] user% ll ll total 80 drwxr-xr-x 10 root wheel 296 Sep 2 23:35 . drwxr-xr-x 3 root wheel 264 Sep 2 23:35 .. -rw-r--r-- 1 root wheel 952 Sep 2 23:35 README -rw-r--r-- 1 root wheel 892 Sep 2 23:35 aliases -rw-r--r-- 1 root wheel 9584 Sep 2 23:35 completions -rw-r--r-- 1 root wheel 433 Sep 2 23:35 environment -rw-r--r-- 1 root wheel 701 Sep 2 23:35 login -rw-r--r-- 1 root wheel 395 Sep 2 23:35 logout -rw-r--r-- 1 root wheel 1959 Sep 2 23:35 rc -rw-r--r-- 1 root wheel 2400 Sep 2 23:35 tcsh.defaults and i have no idea what those scripts are doing. Novajo, I tried /Library/StartupItems but i think i did the script wrong. here's what i put in the script #!/bin/sh ## # Start up seti script ## if [ "${setiathome:=-NO-}" = "-YES-" ]; then { ConsoleMessage "Starting Commandline seti" /Users/username/setiathome } I don't have the slightest clue if this the proper way to call a command line app. BUT one thing i did notice about "Library/StartupItems" folder, does my script also have to be within a folder as well (i'm asking because other scripts that already exist in that DIR are within folders). --WH
__________________
Finally, the power of UNIX! Ti Book 867 G4 Dual 1 Ghz G4 Dual 450 B&W G3 450 (with G4 1Ghz Upgrade) Beige G3 300 |
|
|
|
|
|
#5 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
o i c
you'll be wanting to invoke that setiathome only once when you login, rather for every new terminal window. so, you'll prolly benefit by following the /usr/share/init/tcsh/readme instructions, but disregard that for solving your particular setiathome issue. hmmmm. anyone? can you setup your own ~/Library/StartupItems/ elements and are they invoked on login? i discourage putting junk in /Library/StartupItems if it can be avoided as this would complicate all logins to the box. and you may very well need a vanilla admin login unencumbered by startup junk to fix problems, right? googling... |
|
|
|
|
|
#6 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
well, i couldn't find anyhting about having your own ~/Library/StartupItems, but this is from the bible...
http://developer.apple.com/techpubs/....html#CJBEABGI i think you need a devo account at apple (online devo acct is free) for you to get here, but let us know your results. it mentions that the startup sequence is in flux, so perhaps in the future, there will be hooks into your own startup items, rather than global. |
|
|
|
|
|
#7 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
crap on a crutch! i should get more sleep.
http://www.geocrawler.com/archives/3...1/9/0/6599463/ is that setiathome just a shell script? can you rename that setiathome script to be setiathome.command and hook it up with system preferences->login items renaming a script with a .command extention makes it finder launchable. of course, it's gonna launch terminal app to accomplish this, but that's good. you should have at least seven term app windows open let us know if that work too very good, or what. -- q: how many programmers does it take to change a light bulb? a: it can't be done. it's a hardware problem. |
|
|
|
|
|
#8 |
|
Triple-A Player
Join Date: Jan 2002
Location: CT
Posts: 71
|
mervTormel,
You da man! Well sort of... i tried the ".command" and you are right. it does open another terminal window. I'm going to try a differnet approach with a script.... hopefully i can figure it out by the end of tonight. i'm going to try to write a scipt that will launch seti like so ./setiathome & (this way it will run in the background) then i need to find a way to exit the terminal window Again thanks for your help. --WH
__________________
Finally, the power of UNIX! Ti Book 867 G4 Dual 1 Ghz G4 Dual 450 B&W G3 450 (with G4 1Ghz Upgrade) Beige G3 300 |
|
|
|
|
|
#9 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
yeah, but it'll still hafta launch a terminal window to fork that sucker into the background.
you might try a combo of applescript and terminal command line jiggery-pokery that will clean up after itself. but, i'd just leave terminal open cuz it's fun. |
|
|
|
|
|
#10 |
|
Triple-A Player
Join Date: Jan 2002
Location: CT
Posts: 71
|
mervTormel,
i was thinking the same thing with the applescript combo. But for some reason applescript keeps on locking up. :-/ i have the lastest version of 10 too ggrrr. --WH
__________________
Finally, the power of UNIX! Ti Book 867 G4 Dual 1 Ghz G4 Dual 450 B&W G3 450 (with G4 1Ghz Upgrade) Beige G3 300 |
|
|
|
|
|
#11 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
did you update the developers tools to 10.x.x? i think that was released fairly recently.
|
|
|
|
|
|
#12 |
|
Triple-A Player
Join Date: Jan 2002
Location: CT
Posts: 71
|
yup i have the most current developers tools
__________________
Finally, the power of UNIX! Ti Book 867 G4 Dual 1 Ghz G4 Dual 450 B&W G3 450 (with G4 1Ghz Upgrade) Beige G3 300 |
|
|
|
|
|
#13 |
|
Prospect
Join Date: Jan 2002
Posts: 35
|
You could probably do this by creating a one line applescript in Script Editor and saving as an application (which you would then put in your login panel).
I believe the Applescript command... Code:
do shell script " " I just tested it quickly by using a touch command and it seemed to work... Code:
do shell script "touch ~/filename" |
|
|
|
|
|
#14 |
|
MVP
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
|
Well, I may have misunderstood, but I like to have seti running whenever the computer starts up, not just when I am logged in, so here is what I have:
In /Library/StartupItems/Seti: % ll /Library/StartupItems/Seti/ total 8 drwxr-xr-x 4 root admin 264 Nov 20 20:38 ./ drwxr-xr-x 7 root admin 194 Jan 29 23:01 ../ -rwxr-xr-x 1 root admin 176 Dec 4 07:08 Seti* -rw-r--r-- 1 root admin 194 Nov 20 20:29 StartupParameters.plist Seti contains: #! /bin/sh . /etc/rc.common if [ "${SETI:=-NO-}" = "-YES-" ]; then ConsoleMessage "Starting Seti" cd /PATH/TO /PATH/TO/setiathome -nice 20 >/dev/console & fi And StartupParameters.plist contains: { Description = "Seti at Home"; Provides = ("Seti"); Requires = ("Resolver"); OrderPreference = "None"; Messages = { start = "Starting SETI server"; stop = "Stopping SETI server"; }; } And /etc/hostconfig contains the line: SETI=-YES- This should get you going.... I use the -nice option to make it less intrusive when I am actually working. In fact, I also have a script that checks if Virtual PC is running and if it is sends a 'kill -STOP' to setiathome (causing it to stop running, not to die), because due to the way scheduling works, even 'niced' it is getting CPU when my wife want all cycles to go to VPC (ugh). When it sees that VPC has quit (or is idle for so long) it sends a 'kill -CONT' to wake seti up again. Cheers,
__________________
Douglas G. Stetner UNIX Live Free Or Die Last edited by stetner; 02-01-2002 at 04:45 AM. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|