PDA

View Full Version : Help with ARD UNIX script




bentoms
Jun 18, 2008, 10:00 AM
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;

sudo rm -rf /Library/Caches/com.apple.ATS |
sudo ln -s /private/tmp /Library/Caches/com.apple.ATS |
sudo reboot now

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?



zmttoxics
Jun 18, 2008, 10:11 AM
Try this instead:
#!/bin/bash
rm -rf /Library/Caches/com.apple.ATS
ln -s /private/tmp /Library/Caches/com.apple.ATS
reboot

Then run it like this:
sudo ./file.sh

bentoms
Jun 18, 2008, 12:02 PM
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 (http://www.apple.com/remotedesktop/remoteadministration.html)

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

softwareupdate -l -a

& it works.

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

zmttoxics
Jun 18, 2008, 02:32 PM
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.

yellow
Jun 18, 2008, 02:36 PM
But I think I may have done something wrong a the script doesn't "end."

Does the computer reboot?

chocodup
Jun 18, 2008, 02:48 PM
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 :
cmd1;\
cmd2;\
cmd3

zmttoxics
Jun 18, 2008, 02:51 PM
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 :
cmd1;\
cmd2;\
cmd3

Sorry champ, but a '&' is run the process in the back ground. While '&&' is sequential launching. Bash and KSH do not support parallel launching.

foidulus
Jun 18, 2008, 03:20 PM
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.

yellow
Jun 18, 2008, 03:28 PM
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.

bentoms
Jun 18, 2008, 04:10 PM
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.