Script errors when run by launchd at startup, but not when run in Terminal

I’m attempting to create a RAM disk that loads the previous contents when the system starts up, and every six hours writes the contents to a disk image. Currently, when you run the script from the terminal (“sudo bash LogToRAM.sh”) everything works fine. But when run from launchd during startup, it doesn’t work.

Here’s the lines from the log; the first line just gives some idea as to where in the boot process we are:


SecurityAgent[202] Showing Login Window 
com.mechcozmo.LogToRAM[51] + /Developer/usr/bin/SetFile -a V /Volumes/LogfileRAMdisk 
com.mechcozmo.LogToRAM[51] ERROR: File Not Found. (-43)  on file: /Volumes/LogfileRAMdisk  
com.mechcozmo.LogToRAM[51] + /usr/sbin/asr -source '/Library/Application Support/LogToRAM/RAMdisk_store.dmg' -target /Volumes/LogfileRAMdisk/ -noverify

Here is the script and plist file in question.

Note that ‘set -vx’ is up at the top of the script; it give a lot of information about what is happening in the script.
My current theory is that the /Volumes directory does not exist at this stage of the boot process, but that seems unlikely to be honest.

Answer

You know – that is right. I’ve tried mounting a volume over afp – and it won’t work until you log in. Though I bet you could easily verify this with “does vol exist?” (I forget what that is in shell).

Attribution
Source : Link , Question Author : Community , Answer Author : Community

Leave a Comment