Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > How to create an executable script on a Mac OSX

How to create an executable script on a Mac OSX
Thread Tools
ven
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 11, 2011, 08:04 AM
 
We have a flash application that until now has been used on the Windows platform, and is distributed on a USB. The appliaction is either executed straight from the USB or copied to the PC and executed from the users desired location.

Now our client wants a Mac OSX version of the application.

To have a tidy and nice way to open the application, we have utilized a VBScript on Windows. The file layout is like this:

/Application.exe (created from VBScript, compiled to an EXE file with a nice icon)
/System/TheFlashExecutable.exe


The Application.exe is only launching the TheFlashExecutable.exe, nothing more.

Now I need to replicate the behaviour on a Mac. I have already compiled the application into a Mac version, which runs perfectly.

So how would I create this on a Mac? Like above, I need something like this:

/Applicaion.app (what script or programming environment do i create this file, with a nice icon, from?)
/System/TheFlashExecutable.app
     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Mar 11, 2011, 09:13 AM
 
I don't understand - why not just have the user doubleclick the actual application?
The low-end Mac Pro is the most overpriced Mac since the IIvx
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 11, 2011, 09:31 AM
 
Originally Posted by P View Post
I don't understand - why not just have the user doubleclick the actual application?
One main reason: The main flash executable file is loading lots of files and from folders located at its root directory. Publishing all these files on the root of the USB looks "ugly" and is not user friendly at all. Therefore we have wrapped these files into a "System" folder, so the USB root folder looks nice and tidy.
     
Professional Poster
Join Date: Jun 2001
Location: Northwest Ohio
Status: Offline
Reply With Quote
Mar 11, 2011, 10:38 AM
 
Originally Posted by ven View Post
One main reason: The main flash executable file is loading lots of files and from folders located at its root directory. Publishing all these files on the root of the USB looks "ugly" and is not user friendly at all. Therefore we have wrapped these files into a "System" folder, so the USB root folder looks nice and tidy.
Make an alias of the main flash executable file and put that in the root directory. When the user double clicks it, it will launch as if the user launched the main application from the "System" directory.

Here's how you do it. From the Finder, click on the main flash executable file (single click) to select it. Go to the File menu and choose Make Alias (or press Command-L). Drag the alias out of the "System" directory to the root directory. Done.
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 11, 2011, 12:18 PM
 
I am at home right now, and can not examine the alias closer at them moment - but I recall we tested this earlier.

If I recall correctly, the alias made hardcoded paths which meant that if you copy the USB content to the computer, the alias would stop working.
     
Mac Elite
Join Date: Jan 2000
Location: Columbus, OH
Status: Offline
Reply With Quote
Mar 11, 2011, 12:31 PM
 
Originally Posted by ven View Post
One main reason: The main flash executable file is loading lots of files and from folders located at its root directory. Publishing all these files on the root of the USB looks "ugly" and is not user friendly at all. Therefore we have wrapped these files into a "System" folder, so the USB root folder looks nice and tidy.
OS X applications put all of their resources in a bundle. You don't need a "System" folder. OS X executables are not constructed like Windows exe files.
HyperNova Software, LLC
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Mar 11, 2011, 12:43 PM
 
Originally Posted by ven View Post
One main reason: The main flash executable file is loading lots of files and from folders located at its root directory. Publishing all these files on the root of the USB looks "ugly" and is not user friendly at all. Therefore we have wrapped these files into a "System" folder, so the USB root folder looks nice and tidy.
Not a problem, since applications on OS X are really just folders. Control-click on an application and choose "Show Package Contents" to see what I mean. You can hide as many ugly files as you need inside the application — the proper place to put most things is in Contents/Resources, although executables should go in Contents/MacOS.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 11, 2011, 06:02 PM
 
Originally Posted by CharlesS View Post
Not a problem...
Interesting, I have to read up and test that when I get back to work on monday.

Many thanks guys.
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 14, 2011, 04:25 AM
 
I can not hide the content of my "System" directory in the app file (Appilcation.app/Contents), since it would break the scope of the flash application.

So I need to create an application (*.app) that opens another application (the Flash.app) within its Content folder. I am currently installing Xcode, and as far as I know I can create an app file from applescript with Xcode?

Would that be the easiest options?
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Mar 14, 2011, 05:54 AM
 
You can, but you don't need Xcode for that. You can simply use the Script Editor program which is included with OS X, save your script as an application, and then crack it open and add your files to its contents. Xcode can, of course, get you far greater power and flexibility than Script Editor can, as well as automate the adding of the files to your application's bundle, but if your needs are simple and you don't want to invest the time into learning Xcode, you can probably get by just with Script Editor.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 14, 2011, 06:33 AM
 
Ah, great, it is in the saving options of Script Editor. I just took for granted that I needed another tool to make an app of it.

I have now launched the application with a hardcoded path like this:
do shell script "\"/users/imauser/Desktop/MyApp/System/MyApp.app/Contents/MacOS/Flash Player\" &"

Now I am trying to figure out how to do it with a relative path.
     
ven  (op)
Fresh-Faced Recruit
Join Date: Mar 2011
Status: Offline
Reply With Quote
Mar 14, 2011, 06:43 AM
 
Found it,

tell application "Finder" to get folder of (path to me) as Unicode text
set workingDir to POSIX path of result
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Mar 14, 2011, 02:19 PM
 
Heck, if that's all you're trying to do, you don't even need the script. Just set CFBundleExecutable to "Flash Player" in the Info.plist. This will make your Flash Player into a real Mac OS X application, which will make the user experience a bit better by having the program's Dock icon be the icon of the application instead of the generic executable icon.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:12 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2