New to applescript. need to create a plist file using applescript

Needed some help I need on creatinga plist file below using applescript and I can't make it happen needed some hand on this.
<?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>Username</key>
<string>${localAdminUser}</string>
<key>Password</key>
<string>${localAdminPassword}</string>
<key>AdditionalUsers</key>
<array>
<dict>
<key>Username</key>
<string>${userName}</string>
<key>Password</key>
<string>${userPassword}</string>
</dict>
</array>
</dict>
</plist>
I have tis code but it doesn't seems to work.
tell application "System Events"
  -- create an empty property list dictionary item
          set the parent_dictionary to make new property list item with properties {kind:record}
  -- create new property list file using the empty dictionary list item as contents
          set the plistfile_path to "~/Desktop/example.plist"
          set this_plistfile to ¬
  make new property list file with properties {contents:parent_dictionary, name:plistfile_path}
  -- add new property list items of each of the supported types
  make new property list item at end of property list items of contents of this_plistfile ¬
                    with properties {kind:string, name:"Username", value:"${localAdminUser}"}
  make new property list item at end of property list items of contents of this_plistfile ¬
                    with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
  make new property list item at end of property list items of contents of this_plistfile ¬
                    with properties {kind:list, name:"AdditionalUsers"}
  make new property list item at end of property list items of contents of this_plistfile ¬
                    with properties {kind:string, name:"Username", value:"${localAdminUser}"}
  make new property list item at end of property list items of contents of this_plistfile ¬
                    with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
end tell
The result of the above code will generate a plist file below
<?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>AdditionalUsers</key>
          <array/>
          <key>Password</key>
          <string>${localAdminPassword}</string>
          <key>Username</key>
          <string>${localAdminUser}</string>
</dict>
</plist>

Hello
You need to create elements at correct container. Like this.
set plist_file to (path to desktop)'s POSIX path & "example.plist"
--set plist_file to "~/desktop/example.plist"
tell application "System Events"
    tell (make new property list file with properties {name:plist_file})
        make new property list item at end with properties {kind:string, name:"Username", value:"${localAdminUser}"}
        make new property list item at end with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
        tell (make new property list item at end with properties {kind:list, name:"AdditionalUsers"})
            tell (make new property list item at end with properties {kind:record})
                make new property list item at end with properties {kind:string, name:"Username", value:"${localAdminUser}"}
                make new property list item at end with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
            end tell
        end tell
    end tell
end tell
Or you may create a record in AppleScript and set the value of plist file at once. Like this.
set plist_file to (path to desktop)'s POSIX path & "example.plist"
--set plist_file to "~/desktop/example.plist"
set dict to ¬
    {|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"} & ¬
    {|AdditionalUsers|:{¬
        {|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"} ¬
--set dict to {|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}", |AdditionalUsers|:{{|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"}}}
tell application "System Events"
    tell (make new property list file with properties {name:plist_file})
        set value to dict
    end tell
end tell
Regards,
H
Message was edited by: Hiroto (PS. Fixed second script so that it uses the original case (uppercase)  in key string)

Similar Messages

  • I need to create  .pst  ext . file using java,whi will import in ms outlook

    {color:#ff0000}*I need to create .PST extension file using java which will be able to import in ms outlook,and that .pst file will contain root folder (like Personal Folders) and inbox,sent mail*{color}
    give me some hint It is essential task .we have to implement code in  java

    I'm using the thin drivers.
    The answer to your question is no, you do not need to create a DSN to connect to Oracle. The Oracle thin driver is all that is required. Your code looks OK to me, I'm assuming that you xxx'd out the IP, and that you are using a real IP in the actual code.
    The message you got back is pretty generic, but can indicate that the Oracle database listener isn't available. Perhaps the database is on a different port, or perhaps the listerner isn't running. Perhaps you have the IP address wrong.
    So, to be very basic:
    1) Can you ping the server you are trying to connect to? This makes sure you are using a valid IP address.
    2) Can you connect to the Oracle server from an Oracle client? This makes sure the listener is running properly, and that you know the correct port number and login information (The port number could be in a local or server based TNS file, or available through an Oracle names server. You might try using the program tnsping if it is available on the client for validation.
    3) If you can do 1 and 2, then be sure you are using the same connection parameters (server, port userid and password) that worked with 2.
    4) Verify that you are using (pointing to) the correct set of Oracle classes for the thin connection. This can be tricky if you have different versions of Oracle on the client then on the server, but is documented on the Oracle website.
    5) If everything checks out, you might want to verify that you are using the most recent versions of the thin drivers, including the Oracle patches.
    Hope it helps - good luck,
    Joel

  • Creating a .plist file on AppleTV

    I am trying to finalize the hack of my AppleTV. I need to create a .plist file and have no clue how to do so. Any help would be greatly appreciated.

    With due respect it doesn't sound as though you should be doing this.

  • Why do we need to create an emergency file?

    Please see the link  http://help.sap.com/saphelp_47x200/helpdata/en/9f/db95e635c111d1829f0000e829fbfe/content.htm
    Why do we need to create an emergency file?

    user10566312 wrote:
    Packages I know are used to group procedures together. But why do we create packages when stored proc alone is sufficient.For the same reason there are units in Pascal. Libraries in C. It allows the encapsulation of functionality as a single entity with a public interface and a private implementation.
    It is is standard as far as structured programming goes.
    And a single stored procedure is far from sufficient. It cannot have private and public static variables for keeping state. It cannot present a comprehensive and flexible call interface to the caller. It does not support polymorphism. It cannot expose constants and user types. Etc.

  • I need to create a iTunes account using my work email but...

    I need to create a iTunes account using my work email address but when I try it says that there is already an iTunes account linked to my work email - I have never done this so I know that I have not created this and therefore can't answer the security questions in order to check it out.  It also means I can't set up this iTunes account - any ideas?

    When Apple increased security on the accounts we were asked to create security questions and answers and to offer a rescue email address, could you have used the work address then?
    http://support.apple.com/kb/HT5312

  • Trying to create a certificate file using keytool -help!

    Hi, I've followed a series of instructions using Terminal to create a certificate. Terminal produced a file and when i open it using Text Edit its about 20 lines long worth of code. I was hoping it would provide a certificate I could use. Maybe it has, I just don't know what I'm looking for!
    Im working in Viewer Builder and I'm in the Provisioning tab trying to enter the "Application ID"
    I'm totally stuck here. Please help!

    I'm using DPS pro. My app is for Android but won't be going as far as Google Play or Amazon. It's for internal use so I want to create an APK file to distribute via email. These are the set of instructions I'm following. I'm struggling to get this to work. What should I see when this has worked? Also what do I need to enter for the Application ID?
    Thanks or your help
    (Mac OS) Create a certificate file using Keytool
    Open Terminal, which is located in the Applications > Utilities folder.
    Type (or paste) the following line (replace “myname.key.p12” with the actual name of your certificate):
    1
    keytool -genkey -v -keystore myname.key.p12 -alias alias_name -keyalg RSA -keysize 2048 -storetype pkcs12 -validity 10000
    Specifying “10000” sets the expiration date after 22 October 2033.
    Enter and reenter a password. Until the Viewer Builder supports the creation of custom Android apps, it's necessary to share this password with Adobe. Create a password that you can share.
    Follow the prompts to specify the certificate information.
    When prompted to confirm choices, enter yes, and then press Return to use the same password.
    A certificate is created in your prompt location, such as your user name folder. Copy this certificate file to a known location. Write down the password as well.

  • How to Create a Flat File using FTP/File Adapter

    Can any body done workaround on creating the Flat file using FTP/File Adapter?.
    I need to create a simple FlatFile either using of delimiter/Fixed length. using the above said adapters we can create XML file, i tried concatinating all the values into a single String and writing into a file, but it does not have proper structure
    Can any body help me out on this..
    Thanks
    Ram

    You can create a text schema while creating a File Adapter. If schema is specified for File Adapter, it takes care of converting XML into fixed length or delimited format.
    Thanks,
    -Ng.

  • Export to PDF - Can a single report (rpt file) create multiple PDF files using the export command?

    Post Author: markeyjd2
    CA Forum: Exporting
    Greetings forum members,
    My question is, in its entirety: Can a single report (rpt file) create multiple PDF files using the export command, ideally one PDF file per DB record?
    In my case; I have a Crystal Report that reads data from a DB table containing ~ 500 records.  When I export the report to a PDF file, I get one PDF file, with ~ 500 pages.
    What I would like to do is export the report to ~ 500 individual PDF files; One file per DB record.  The file names would be based on the table's primary key.
    Is this possible?

    Post Author: Micha
    CA Forum: Exporting
    Hi,
    you need some lines of code, but its easy. Dependend on how to start the generation of your 500 PDFs, you can write an ASP page and start it via Web Browser, or a Windows Script and start it via scheduled job...
    Here's an abstract of the ASP code I use:
    First, you create a recordset (here: "rsc") which gives you the list of ID fields you want to export, then you create CrystalRuntime.Application object, then you loop through the recordset, open your report (here: "oRpt") and set login info. Then set the selectionformula, so that the report displays only the data of the current ID, e.g.:
      oRpt.RecordSelectionFormula = "(" & oRpt.RecordSelectionFormula & ") AND {myTab.myVal}=" & rsc("myVal")
    Then you export the report, move to the next record in recordset, and repeat the loop until recordset.EOF. Then you close recordset and connection.
    Micha

  • Create BPEL jar file using Bpelc via Java classes

    HI,
    I am trying to create the BPEL files ( xyz.bpel, bpel.xml, xyz.wsdl etc.. ) on the fly using Java code... Once I create all these files, I create a packaged jar (Ex : bpel_xyz_v2006_10_17__37256.jar) file and deploy the same in the Bpel PM.
    Right now, in order to create the jar file, I am running the bpelc.bat file under bpel/bin and then using the IBPELDomainHandle, I am deploying the process.
    But my requirement is to create the jar file using java rather than executing the bpelc.bat file..
    Can you please give me pointers as to how to achieve the same?
    Thanks
    Pramod

    Actually, I had figured out the part of calling the Bpelc class, but initially I was trying to create an object of the class and was not able to do so. That was where I got stuck.
    Eventually, I did something like the code snippet below and it works fine and the jar file is created. Just fyi for anyone looking in the future.
    String[] setupValues;
    setupValues = new String[]{ "-home", "D:\\product\\10.1.3.1\\OracleAS_1\\bpel", "-rev",
    "1.0", };
    Bpelc.main(setupValues);
    Thanks
    Pramod

  • Creating a text file using pl/sql

    how can one create a text file using pl/sql?
    Say for example abcd.txt in the d: drive
    (d:\abcd.txt)
    on a windows nt server

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by bhrigu nagal ([email protected]):
    thanks for your replies
    I had already set the utl_file_dir parameter
    I tried the utl package and wrote the following code but got some errors
    declare
    filehandler UTL_FILE.FILE_TYPE;
    begin
    filehandler:=UTL_FILE.fopen('d:/intel/','myfile.txt','w');
    utl_file.put_line(filehandler,'look masjdfgsd\n');
    utl_file.fclose(filehandler);
    exception when utl_file.invalid_path then
    raise_application_error(-20023,'bhrigu ,chk the path');
    end;
    the errors
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_FILE", line 101
    ORA-06512: at "SYS.UTL_FILE", line 157
    ORA-06512: at line 4
    if u know what this is please tell me
    thanks bhrigu
    <HR></BLOCKQUOTE>
    U need :
    1) To have UTL_FILE_DIR param in the init file of the instance with the same directory (don't forget to stop and restart the base)
    2) Handled the exceptions listed in the utl_file package (Oracle_home\rdbms\admin\utlfile.sql) in your source.
    3) Turn set serveroutput on in SQL*Plus.
    Run your procedure and see the error message to debug.
    Good luck
    null

  • Create crystal report file using JAVA

    Can someone tell me how to a Create crystal report file using JAVA Programming
    I want a very simple example

    Please help me. It's urgent.[http://catb.org/~esr/faqs/smart-questions.html#urgent]
    Be back in an hour or two...

  • I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel

    I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel.
    When it was explained to me it didn't sound to hard of a task, I have no LabVIEW experience and the tutortial sucks.

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • New to Illustrator, need help creating a map?

    Need to create a map of a neighborhood.  New to program any help would be great!

    rdelaroca,
    There are vector maps available for many areas.
    Or you may work on a locked image from Google Maps or something including the important parts/themes/whatever, using the Pen Tool as the primary tool for shapes in general.

  • Need help creating folders and files in Pathfinder

    Hi, I have tried the Pathfinder forum but it's a ghost town over there. I don't know if this is a PF or Finder issue yet.
    I've just installed Pathfinder 5.2.2 on an iMac running OS 10.5.8 at my new job.
    The problem is I can open files and folders from within Pathfinder but I can't create any new files or folders from within Pathfinder, and I also can't drag anything from the drop stack to a new location either. I've made sure to set permissions for read/write on my Mac HD and on the PF application itself, and I've repaired my permissions, and also run Cocktail, restarted the mac, quit PF etc. Still nothing.
    Anything that could point me in the right direction would be greatly appreciated.

    Hi Kappy,
    When I try to move a folder or file, or create one, nothing happens at all. It's as if I never did anything. I am able to open files from within Pathfinder and navigate my Hard Drive, but I cannot create or delete files.
    I posted on their forum, which is what they suggest. I've used Pathfinder for several years, I have no questions on the actual interface, but I wonder if there might be a permissions issue on this particular mac.

  • Need to create a flat file source system in bi?

    Hi all,
    i need to load the data from a flat file to an ods? can anyone pls tell me the steps to create the flat file source system in bi?
    Thanks

    Hello,
    http://help.sap.com/saphelp_nw70/helpdata/en/43/01ed2fe3811a77e10000000a422035/content.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/80/1a6581e07211d2acb80000e829fbfe/frameset.htm
    steps:
      create source system file (if you haven't)
    - create ods
    - create update rules for ods and activate
    - create infosource
    - assign infosource with datasource (source system file)
    - maintain transfer rules - maintain infoobject in sequence as flat file to transfer structure. map infoobject in transfer rules. activate transfer rules
    - create update rules ods-infosource and activate
    - create infopackage, specify external data path (recommended file put in application server)
    hope this helps.
    Regards,

Maybe you are looking for

  • Opening Safari PDFs in Acrobat

    I used to have Safari set to open PDFs in Acrobat. Since updating Safari (5.1) and Lion, all PDFs in Safari open in a new Safari tab. I used to click on a link to a PDF in Safari, the document would automatically download to my mac, and automatically

  • Wishlist for next N95 FW version (¿v21?)

    Just to see what comes up, what would you like included in the next N95 FW version? Here's my wishlist: - SIP incoming calls problem (see /discussions/board/message?board.id=smartphones&thread.id=69938 ) - Cable Headphone problem fix (see /discussion

  • Oracle 9i rac spfile in raw

    We have a 9i Oracle RAC which uses init.ora files for two nodes instead of the shared spfile. The spfile is created in a shared raw device but it is not being used. I would like to fix that. I have two possible methods I would like to confirm Method

  • IPhoto crashes when importing groups of large, scanned images

    I have a folder of 16 scanned images, that range in size from 3 MB to 50 MB (first time scanning and scanned at really high resolution so they could be blown up in books or calendars - have learned better since). iPhoto quits when I try to import the

  • Mismatch in connection between session and cmpentity beans

    Hello everybody, I have a adopted JSP----SessionBeans------CMPEntityBeans------Database (MVC2). I have findByIdandPasswd(String id,String passwd) method in Entity's LocalTurbineUserHome its return type is Collection. This method is called in my sessi