Very simple "shell script" help?

Discussion in 'Mac Programming' started by mavis, Oct 13, 2007.

  1. mavis macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #1
    Hey guys,

    I'm sorry to post such a stupid question, but I'm really lost here - this is my first Mac and it's only a few days old, so I have no idea what I'm doing. I've tried Googling this but the results are way over my head ... :(

    Basically I have two Terminal commands that I'd like to run every time I login. The commands are:

    Of course I'd like my password entered automatically as well - I would just like this to happen as quickly as possible, in the background, every time I login. I've been told I can do this with a script, but I don't even know where to begin. Any ideas? For example, if my password is 12345, how would I put this whole thing into a script and have it run every time I login?

    If anyone has any idea how to do this, I'd really appreciate your help!
     
  2. todd2000 macrumors 68000

    Joined:
    Nov 14, 2005
    Location:
    Danville, VA
    #2
    Not really sure, but I don't think "sudo ./wizd" is a valid command. What are you trying to do exactally?
     
  3. SC68Cal macrumors 68000

    Joined:
    Feb 23, 2006
    #3
    No, it is.

    What is wizd? Why are you launching it with root privs?
     
  4. todd2000 macrumors 68000

    Joined:
    Nov 14, 2005
    Location:
    Danville, VA
    #4
    doh I didn't stop to think that wizd might be an application, I though it was his username or something :)
     
  5. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #5
    It's a media server for my Avel LinkPlayer 2, apparently the only way to get it to run is to give it superuser privileges ... I ran it for a couple of years on my Windows box, I set it up to run as a service so it was totally transparent - every time I booted up, it ran automatically in the background. I'd like to do something similar with this iMac if possible - I just want to have it running all the time (because there's nothing more annoying than sitting down for dinner, turning on on the TV, and getting a "Server cannot be found" message when all I want to do is watch some Simpsons or Smallville or something) ... ;)

    Any help would be greatly appreciated!
     
  6. SC68Cal macrumors 68000

    Joined:
    Feb 23, 2006
    #6
    You could give it a SUID bit, so you don't have to invoke sudo all the time.

    If you trust the app...... SUID bits aren't just given out like popsicles. I'd reccomend updating to the latest version to ensure you're secure.

    Code:
    sudo chown root wizrd
    sudo chmod 4755 wizrd
     
  7. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #7
    Thanks you for the reply. I tried doing this but it didn't work - when I logged back in I was unable to launch WizD until I did the original commands (in the first post here) ...

    I guess what I need is a way to enter these terminal commands:

    Code:
    cd /Applications/WizD/
    [press enter]
    sudo ./wizd
    [press enter]
    12345 (whatever my password is)
    [press enter]
    [quit terminal]
    
    Is anything like this possible? Thanks again for you r help, I appreciate it :)
     
  8. SC68Cal macrumors 68000

    Joined:
    Feb 23, 2006
    #8
    You must not be doing it correctly. The whole point of a SUID bit is so that you don't have to invoke sudo to get it to run at the root level.
     
  9. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #9
    Wow, you're right - I must've messed something up because I just tried it again and this time it worked perfectly. :D

    Thanks so much for your help!!!! This was the last Windows app I really wanted to have running smoothly on the Mac, and now it's done! Thank you!

    One little question, though - now that I've added wizd to my login items, it leaves a Terminal window open when it loads. Not a huge deal, but is there any way to get it automatically quit Terminal once it has loaded?
     
  10. Mernak macrumors 6502

    Joined:
    Apr 9, 2006
    Location:
    Kirkland, WA
    #10
    just add
    Code:
    killAll Terminal
    to the end of the shell script.
     
  11. todd2000 macrumors 68000

    Joined:
    Nov 14, 2005
    Location:
    Danville, VA
    #11
    He isn't using a shell script.

    In you Log-In Items try checking the "Hide" box next to wizd, and see if that gets rid of the terminal.
     
  12. Mernak macrumors 6502

    Joined:
    Apr 9, 2006
    Location:
    Kirkland, WA
    #12
    my bad, I read it as /.wizd and was wondering why an application would be hidden so I figured he was using a shell script instead of Finder. So, I would agree with checking the "Hide" box (but that would still annoy me)
     
  13. todd2000 macrumors 68000

    Joined:
    Nov 14, 2005
    Location:
    Danville, VA
    #13
    Why would that annoy you? Click the box one time, and forget about it.
     
  14. jbstew32 macrumors regular

    Joined:
    Jan 15, 2007
    #14
    this is really only 1 command: sudo /Applications/WizD/wizd

    The only question is 'how do I run this upong login with root permissions?'

    here's a link that should help: http://docs.info.apple.com/article.html?artnum=301446

    That explains how to run a shell script at login, but I have never tried it. If it gives you trouble because wizd is an application and not a script, then just make a simple bash script that starts the application.

    ie


    #!/bin/bash
    /Applications/WizD/wizd &
    exit 0



    or something along those lines...
     
  15. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #15
    Actually, clicking the box didn't do the trick - Terminal still pops up whenever I log in. It's really not the end of the world though, and if OSX is as stable as everyone seems to think, I guess I probably won't be re-booting often enough for it to be an annoyance. ;)

    Anyway I want to thank everyone for the great advice here - I've got it set up and working and I really appreciate the help!! :D
     
  16. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #16

    I'm sorry to resurrect such an old thread, but I'm still having problems with this :(

    Following the instructions here, I got things to work perfectly, for about a week, but ever since then I've had to go about this the way I posted above (first post in this thread) to get WizD to work. Does anyone here have any ideas about how I can get this stupid server to launch automatically when I turn on my Mac?

    Any help would be GREATLY appreciated!
     
  17. mavis thread starter macrumors 68040

    mavis

    Joined:
    Jul 30, 2007
    Location:
    Tokyo, Japan
    #17
    Wirelessly posted (iTouch 1.1.2 (JB'd): Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3)

    Hmm ...

    So is what I'm trying to do simply not possible on a Mac?
     
  18. weinrdog macrumors newbie

    Joined:
    Oct 25, 2007
    Location:
    o-HI-o
  19. sreedy macrumors 6502a

    Joined:
    Feb 24, 2005
    Location:
    Somerset
    #19
    Check the ownership\permissions haven't been changed back by something:

    ls -ltr ~/Applications/WizD/wizd
     
  20. fimac macrumors member

    Joined:
    Jan 18, 2006
    Location:
    Finland
    #20

Share This Page