0

I am trying to create a script to run from a Casper Server, I have managed to get the script to capture the current logged in user and I would like to move the fonts out of their ~/Library/Fonts/ folder.

I just keep getting an error that the folder does not exist, I think it is because I am trying to go to the hidden library folder, originally I thought it was because it couldn't find the "FontsRemoved" folder so I changed that to a variable too and I am still getting the error. Can someone assist with how I should maybe be calling this? I need to set user folders back to default for SOX compliance and I would rather have a backup of the fonts rather than overwriting the folder with a DMG of the folder, just in case there are fonts that the user require.

mkdir -m 777 /Users/Shared/FontsRemoved/

user=`/bin/ls -la /dev/console | /usr/bin/cut -d " " -f 4`

fontsfolder=/Users/Shared/FontsRemoved/

"mv /$user/Library/Fonts/* $fontsfolder"
  • Here is the error I am getting btw: /bin/bash: line 7: mv /room.one/Library/Fonts/* /Users/Shared/FontsRemoved/: No such file or directory – MrTrigger May 8 '17 at 16:10
  • 1
    mv /Users/$user/Library/Fonts/* $fontsfolder" – user4556274 May 8 '17 at 16:21
  • 1
    @MrTrigger Add that to the question, not a comment – Barmar May 8 '17 at 20:04
  • 1
    Don't put the command to execute inside quotes. – Barmar May 8 '17 at 20:04
1

The last command in your script is

"mv /$user/Library/Fonts/* $fontsfolder"

You get mv /room.one/Library/Fonts/* /Users/Shared/FontsRemoved/: No such file or directory because it tries to find a command with that name, including spaces.

That's because you have put the whole line in double quotes.

Instead, do

mv /"$user"/Library/Fonts/* "$fontsfolder"

or

mv /home/"$user"/Library/Fonts/* "$fontsfolder"

or

mv /Users/"$user"/Library/Fonts/* "$fontsfolder"

depending on where your home directories are located.

  • Thanks so much, the last line worked for me, that was driving me crazy! – MrTrigger May 9 '17 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.