Help with ARD UNIX script

Discussion in 'Mac Programming' started by bentoms, Jun 18, 2008.

  1. macrumors regular

    Joined:
    Mar 23, 2006
    #1
    Hi guys, dunno if tis should have been posted here or in the Server forum but here goes nothing!!

    I have a UNIX script that fixes a font cache issue that sometimes affects the Macs that I support.

    The Script is this;

    But I think I may have done something wrong a the script doesn't "end."

    i.e. it runs as it should, but doesn't terminate to say that's done.

    So what have I missed?
     
  2. macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    #2
    Try this instead:
    Code:
    #!/bin/bash
    rm -rf /Library/Caches/com.apple.ATS 
    ln -s /private/tmp /Library/Caches/com.apple.ATS 
    reboot
    Then run it like this:
    Code:
    sudo ./file.sh
     
  3. thread starter macrumors regular

    Joined:
    Mar 23, 2006
    #3
    Thanks zmttoxics but that doesn't work as the file is not located on the remote machine.

    I am sending this UNIX command from Apple Remote Desktop

    So you can use the Send UNIX command & type in something like;

    & it works.

    But I'm just not sure how to send a multi-line command.
     
  4. macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    #4
    If you use && that should work. cmd 1 && cmd 2 &...

    Though, I now realize this is ARD specific (early morning today :p) so that may not work as its actually the bash method.
     
  5. Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #5
    Does the computer reboot?
     
  6. macrumors member

    chocodup

    Joined:
    May 17, 2008
    #6
    I am not sure about the shell version you need to use.

    In Bourne/Korn shell :
    - the "cmd1 ; cmd2" command line launches cmd2 after cmd1 complete execution (=serial processes)
    - the "cmd1 & cmd2" command line launches both cmd1 and cmd2 at the same time (= parallel execution)

    In C shell, I am not sure there is a parallel execution syntax, but the serial one is the same as for Bourne/Korn shell.

    => try the ';' separator between your commands, you can use the '\' character if you want to have multiple lines :
    Code:
    cmd1;\
    cmd2;\
    cmd3
     
  7. macrumors 65816

    zmttoxics

    Joined:
    May 20, 2008
    #7
    Sorry champ, but a '&' is run the process in the back ground. While '&&' is sequential launching. Bash and KSH do not support parallel launching.
     
  8. macrumors 6502a

    Joined:
    Jan 15, 2007
    #8
    I would try the reboot as a separate task

    I haven't had very much luck doing reboots via the command line, esp. on macs that got into a stupid state.

    I would just run the first two commands, then do another reboot command using ARDs reboot.
     
  9. Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #9
    Another issue...

    Do not use sudo. Sudo expects a password interaction within the shell.

    Simple do the command and leave sudo out, and then choose the Run Command as and enter root as the user.

    This is probably why nothing is working.
     
  10. thread starter macrumors regular

    Joined:
    Mar 23, 2006
    #10
    thanks for the replies guys.

    I think that as I'm asking it to reboot it's not giving ARD a proper exit, so does not appear to be terminating.

    As soon as another Mac has the issue i'll try the above & let you know what happens.

    I have a feeling that just typing the commands & hitting return at the end if each line should be ok. It's probably just the GUI throwing me.

    Oh & I forgot to remove the sudo, I will be rubbing this as root.
     

Share This Page