Tuesday, January 15, 2008

Apple .command executed on mounted image

SOLUTION:
  1. Create a command line program and make it execution clickable in Finder interface, by appending .command
    e.g. myexe.command
  2. Wrap this up in a .dmg file, which is mountable once it is clicked on (it is how most mac programs are distributed from websites)
USAGE:
  1. User clicks twice, once on the URL (e.g.) http://example.com/yoursoftware.dmg
  2. User sees the mounted image in their Finder interface, and sees the (e.g.) myexe.command
  3. User clicks on myexe.command
IMPLEMENTATION:
  1. Create a shell executable.
    vi myshellscript.command
    #!/bin/bash
    ls -l
  2. Make it executable.
    sudo chmod 0777 myshellscript.command
  3. Put into directory as the only file.
    mkdir downloads
    mv myshellscript.command downloads/
  4. Create a .dmg file
    hdiutil create -srcfolder downloads -volname MyDownloadable MyDownloadable
  5. Click on MyDownloadable.dmg
  6. Click on myshellscript.command

No comments: