*Mac Experts* Running a terminal command on startup? *Help*

Discussion in 'OT Technology' started by DjShiznit, Jun 25, 2006.

  1. DjShiznit

    DjShiznit Representing Deutschland, yah.

    Joined:
    Oct 8, 2001
    Messages:
    3,963
    Likes Received:
    1
    Location:
    PNW
    I'm still fairly new to Macs. I loaded desktop manager, and did all the smackbook crap. It's pretty cool, and will definitely be useful after I get my 2gb ram in the mail. I was wondering... In order to let the desktop manager read the sudden motion sensor, you need to open the terminal and run "perl smack.pl" from the folder the file is located in. Would there be any way to have this automatically run on startup? Would it be possible to have it automatically hide the terminal? Thanks in advance!

    Also, I'd like to have the desktop manager load on startup, but can't figure out how to have that load either :mad: Help?
     
    Last edited: Jun 25, 2006
  2. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    Make sure the first line is:
    #!/usr/bin/perl

    then type this in the console where your file is:
    chmod +x smack.pl

    That makes the file executable, you can run it now by simply typing: ./smack.pl. You should be able to add it to your start up items. (control panel > accounts)
     
  3. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    Whoops, I meant login items.
     
  4. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    rc.local

    .bashrc
     
  5. DjShiznit

    DjShiznit Representing Deutschland, yah.

    Joined:
    Oct 8, 2001
    Messages:
    3,963
    Likes Received:
    1
    Location:
    PNW
    First line where?


    OK, did that. Nothing happened. No errors or anything. When I double click the file, it tries to open it with text edit :-/

    OK. When I type "./smack.pl" in the terminal, I get this :-/

    ./smack.pl: line 1: use: command not found
    ./smack.pl: line 3: my: command not found
    2006-06-25 20:58:02.832 open[246] No such file: /Downloads/Smackbook Pro/smackbook Folder/F,./AMSTracker -s -u0.01 |
    ./smack.pl: line 6: syntax error near unexpected token `)'
    ./smack.pl: line 6: `while(<F>) {'

    God damn why can't I know UNIX like I know DOS. A simple batch file would do :-/
     
  6. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    yeap, edit the first line of the file to be
    #!/usr/bin/perl


    Edit: INSERT it on top of the file, dont change the first line.
     
  7. DjShiznit

    DjShiznit Representing Deutschland, yah.

    Joined:
    Oct 8, 2001
    Messages:
    3,963
    Likes Received:
    1
    Location:
    PNW
    OK I inserted that string of text above the first line of the file, dragged it to my login items... When the system boots up, it opens the file in text edit? Ugh, I give up. Is there any way to replace unix with dos? :mamoru: Seriously though, I don't see why it should be such a struggle to get this thing to run the terminal, go to the folder where the file is located, and run the command "perl smack.pl" every time it starts up. That's all I'm trying to acomplish. Yeah, I can do it manually - but that's annoying. Would be nice if it was just automated at startup. Even better if it hid the terminal and ran in the background. :-/
     
    Last edited: Jun 26, 2006
  8. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    okay to be honest i'd never tried a script in login items. Looks like mac os is treating it as a file & not executing it. You'll have to go with peyomp's suggestion and add the command into one of the login files he suggested.
     
  9. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    I would add this line to /etc/rc:

    /path/to/smackdown/smack.perl&

    just before the last lince that says exit 0

    Should work.
     

Share This Page