How to pass parameters in .plist files?

Discussion in 'Mac Programming' started by AgentSmith, Nov 4, 2008.

  1. AgentSmith macrumors newbie

    Joined:
    Jul 16, 2008
    Location:
    Australia
    #1
    Hi

    I want to start up mysql automatically and have created a plist file to do so, and placed it in the LaunchDaemons directory....but... i start mysql with "mysqld_safe --user=root" and don't know the correct way of passing the --user=root parameter to mysqld_safe.

    eg part of the plist file:

    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/var/root/mysql/bin/mysqld_safe</string>
    <key>ProgramArguments</key>
    <array>
    <string>--user=root</string>
    </array>

    doesn't seem to work. neither does

    <key>Program</key>
    <string>/var/root/mysql/bin/mysqld_safe --user=root</string>

    Help appreciated :)
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    A simply Google search reveals numerous pages with the answer on them. This one seems particularly good...
     
  3. AgentSmith thread starter macrumors newbie

    Joined:
    Jul 16, 2008
    Location:
    Australia
    #3
    Thanks for the link. My google search didn't turn up anything particularly useful.

    Worked out that I needed to do this:

    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/var/root/mysql/bin/mysqld_safe</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
    <string>/var/root/mysql/bin/mysqld_safe</string>
    <string>--user=root</string>
    </array>


    instead of:

    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>Program</key>
    <string>/var/root/mysql/bin/mysqld_safe</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
    <string>--user=root</string>
    </array>
    </dict>


    I was assuming that setting the Program string would launch the program and program arguments would be the parameters, which isn't the case. Seems that the First argument needs to be the program and the following arguments are the parameters.

    Thanks again. Now mysql starts automatically when I reboot my iphone :D
     

Share This Page