7stud -- wrote in post #997885:
>
> Yeah, what is so hard about posting a sample of the original file, as
> well as the modified file that you want to end up with, and leaving out
> all your confusing descriptions?

OK, here's the inbound:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>PayloadContent</key>
  <array>
    <dict>
      <key>EmailAddress</key>
      <string>{username}</string>
      <key>Host</key>
      <string>exchange.domain.com</string>
      <key>MailNumberOfPastDaysToSync</key>
      <integer>3</integer>
      <key>Password</key>
      <string>{password}</string>
      <key>PayloadDescription</key>
      <string>Configures device for use with Microsoft Exchange 
ActiveSync services.</string>
      <key>PayloadDisplayName</key>
      <string>Exchange</string>
      <key>PayloadIdentifier</key>
      <string>com.domain.enterprise.eas</string>
      <key>PayloadOrganization</key>
      <string>TipsHouse</string>
      <key>PayloadType</key>
      <string>com.apple.eas.account</string>
      <key>PayloadUUID</key>
      <string>FE477C13-BF4F-4EA0-BE09-3968EC40C952</string>
      <key>PayloadVersion</key>
      <integer>1</integer>
      <key>SSL</key>
      <true/>
      <key>UserName</key>
      <string>domain\{userroot}</string>
    </dict>
  </array>
  <key>PayloadDescription</key>
  <string>Profile Test</string>
  <key>PayloadDisplayName</key>
  <string>TipsHouse</string>
  <key>PayloadIdentifier</key>
  <string>com.domain.enterprise</string>
  <key>PayloadOrganization</key>
  <string>Domain</string>
  <key>PayloadRemovalDisallowed</key>
  <false/>
  <key>PayloadType</key>
  <string>Configuration</string>
  <key>PayloadUUID</key>
  <string>A6B7D66D-1179-4E85-A005-4DAACD4EDF0F</string>
  <key>PayloadVersion</key>
  <integer>1</integer>
</dict>
</plist>

And the outbound replaces elements in only the array area (in this case, 
just the EAS but other options may be included - LDAP, IMAP, etc.)
<dict>
      <key>EmailAddress</key>
      <string>greghacke / domain.com</string>
      <key>Host</key>
      <string>exchange.domain.com</string>
      <key>MailNumberOfPastDaysToSync</key>
      <integer>3</integer>
      <key>Password</key>
      <string>MyPassword</string>
      <key>PayloadDescription</key>
      <string>Configures device for use with Microsoft Exchange 
ActiveSync services.</string>
      <key>PayloadDisplayName</key>
      <string>Exchange</string>
      <key>PayloadIdentifier</key>
      <string>com.domain.enterprise.eas</string>
      <key>PayloadOrganization</key>
      <string>TipsHouse</string>
      <key>PayloadType</key>
      <string>com.apple.eas.account</string>
      <key>PayloadUUID</key>
      <string>FE477C13-BF4F-4EA0-BE09-3968EC40C952</string>
      <key>PayloadVersion</key>
      <integer>1</integer>
      <key>SSL</key>
      <true/>
      <key>UserName</key>
      <string>domain\greghacke</string>
    </dict>

Now, the initial file is provided to me may be replaced as needed. I 
would like to avoid converting it to ERb as I cannot gaurentee anyone 
else will do the work to ensure it stays updated and correct.

I've dug around - really - and found two examples for single element 
replacement.

My belief is that there are a plethora of options execute this. I would 
like to do something like:
File.copy(master,user_file)
File.open('/tmp/temp_file.txt', 'w+') do | new_file |
     new_file.puts(File.open(user_file, 'r') do | original_file |
     original_file.read.gsub(/\{username\}/, username)
     end)
end
FileUtils.mv("/tmp/replaceable2.txt", user_file)

  text= File.read user_file
  File.open(user_file, 'w+'){|f| f << text.gsub(/\{username\}/, 
username)}

-- 
Posted via http://www.ruby-forum.com/.