distributing XML for SAP 7.70

SebastianH
New Contributor II

Hi Together,

first a thank you for all the help I get here as a "newbie" from all of you.

I am currently distributing SAP for JAVA 7.70 the package works without any problems. SAP works fine

but what I can't manage yet is to distribute the XML.

I have built a PKG using Packages which should copy the XML to /Users/USER/Library/Preferences/SAP

but instead the XML ends up in /Library/Preferences/SAP

where did I make a thinking error ?
probably it is something very simple that I just don't see

thanks for the answers

1 REPLY 1

mm2270
Legendary Contributor III

For something like this, where the file needs to end up in a user's Preferences folder, I'd consider using a script instead of a package. Since an XML file is just text, the file can be created on the fly in a script easily enough. The advantage of this method is you can get the current user information directly in the script. You can also change the contents of the XML file and the location of where it gets created easily without needing to repackage anything.

Something like this should work.

#!/bin/sh

## Get the current user logged in on the Mac
logged_in_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ {print $3}')

## This variable defines the place where the xml will go. Change "filename.xml" to the correct name for the file
path_for_xml="/Users/${logged_in_user}/Library/Preferences/SAP/filename.xml"

## Create the XML. You will need to copy/paste the unaltered XML file contents over the < all xml data goes here > section
cat << EOXML > "${path_for_xml}"
< all xml data goes here >
EOXML

## Make adjustments to the ownership and permissions here, otherwise the logged in user may not be able to read the file contents
/usr/sbin/chown $logged_in_user "$path_for_xml"
/bin/chmod 744 "$path_for_xml"

Give something like this a try and see if it helps.