Skip to main content

# This is a script I found for Chrome, it runs successfully in CodeRunner, but I can't move the file where I want:
Any help would be appreciated



!/bin/bash



CHROME_BOOKMARK="$HOME/AppData/Local/Google/Chrome/User Data/Default/Bookmarks"
alias bmcsync='cp "$CHROME_BOOKMARK" "/d/someRepo/b-1 backup/5-1 bookmark/"'



I added the path to the end, but get an error
if I use "man bmcsync" I get command not found

Hi @bconcertiv,
While the "$HOME" variable may work natively on your computer, Jamf runs as root so the expected folder will often be different. To resolved this, most Jamf admins determine the actual user's file path by using



currentUser=$( /usr/bin/last -1 -t console | awk '{print $1}' )


You can test backing up the user's bookmark with this script:



#!/bin/bash
#Script to backup Chrome bookmark file to a specified location
#Shaquir Tannis 6-30-20

#Get current user
currentUser=$( /usr/bin/last -1 -t console | awk '{print $1}' )

#Chrome bookmark location
userChromeBookmark="/Users/"$currentUser"/Library/Application Support/Google/Chrome/Default/Bookmarks"

#Location to save bookmark
backupBookmark="/path/to/backuplocation/"

#Check if file exists and backup if it does
if [[ -f "$userChromeBookmark" ]]; then
#Backup Chrome bookmark file
cp "$userChromeBookmark" "$backupBookmark"
else
echo "No Bookmark file found"
fi

@shaquir Thank you this works perfectly. I really appreciate it.


The currentUser line above no longer works in Ventura. Swap in:

currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕 && ! /loginwindow/ { print $3 }' )

 

Everything else works fine in Ventura.  


Reply