Shell scripts must be executable files in order to run. Dymo label software mac el capitan. You can use the chmod command to indicate that the text file is executable (that is, its contents can be run as a shell script). In the Terminal app on your Mac, use the cd command to move into the directory that contains the file you want to make executable. Apr 04, 2018 I presume that you're talking about the OS X installer itself. The.app contains additional files (the.dmg is one of the files inside the.app). The easiest solution is to go to the App Store on a working system and download a full copy of the installer from there. Appify — create the simplest possible Mac app from a shell script Alternatively, you can use Thomas Aylott's appify script to bundle your shell script into an OS X application. Mathias Bynen's article walks through how to use the script, how to create simple Mac apps from shell scripts. Let's say you have a shell script called foo.sh. Do this: mkdir -p foo.app/Contents/MacOS mv foo.sh foo.app/Contents/MacOS/foo chmod +x foo.app/Contents/MacOS/foo Done. Double-click foo.app (which the Finder shows you as simply 'foo') and your shell script runs. No developer tools required, and it doesn't depend on fragile metadata like this. Jun 25, 2015 Drag in a Run Shell Script action from the Utilities library. Copy and paste the above code into the action, replacing “cat' Save the Service. Open Keyboard System Prefs. Click on Shortcuts Tab. Select Services from the category list. Scroll down and find your Service and set the shortcut.
Some Macs have the WiFi port is not 'en1' as in the Barney-15E's script (ex: MacBook Pro Retina 15 with Yosemite).
So, the script will work for switch WiFi to ON only.
I think it's regular for new Apple laptops without Ethernet RJ45 port.
To solve the problem it should be define which en* port is WiFi in the system.
I used the Terminal command:
$ networksetup -listallhardwareports
and find my WiFi as 'en0' :
$ networksetup -listallhardwareports
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 12:00:7h:cb:c7:11
So the Barney-15E's beautiful script changed to:
if [[ `networksetup -getairportpower en0` *On ]]
then
networksetup -setairportpower en0 off
else
networksetup -setairportpower en0 on
fi
Another way to create Finder-clickable shell scripts | 30 comments | Create New Account
Click here to return to the 'Another way to create Finder-clickable shell scripts' hint |
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another way to create Finder-clickable shell scripts
Another way to create Finder-clickable shell scripts
There's a better way.
Let's say you have a shell script called foo.sh. Do this:
mkdir -p foo.app/Contents/MacOS
mv foo.sh foo.app/Contents/MacOS/foo
chmod +x foo.app/Contents/MacOS/foo
Done. Double-click foo.app (which the Finder shows you as simply 'foo') and your shell script runs. No developer tools required, and it doesn't depend on fragile metadata like this hint does.
Let's say you have a shell script called foo.sh. Do this:
mkdir -p foo.app/Contents/MacOS
mv foo.sh foo.app/Contents/MacOS/foo
chmod +x foo.app/Contents/MacOS/foo
Done. Double-click foo.app (which the Finder shows you as simply 'foo') and your shell script runs. No developer tools required, and it doesn't depend on fragile metadata like this hint does.
Another way to create Finder-clickable shell scripts
I tried this one, cause I like it better than the previous hint -- I can add a nice icon and other frills! -- but this failed for me..
The Finder decided that my foo.app was a Classic App, but didn't bring up the Classic Environment. My script is woefully simple -- it simply calls a Terminal-based executable -- which now launched in the background, with no user interaction..
So I'll stick to the following, as in the older hint, for now -- just change your
foo.sh
to
foo.command
and presto -- auto-launch of the Terminal, and auto-run of the script therein, complete with user interaction.
---
Ted Thibodeau Jr -- Technical Evangelist -- OpenLink Software
Ted Thibodeau Jr -- Technical Evangelist -- OpenLink Software
Another way to create Finder-clickable shell scripts
You also have to create a file foo.app/Contents/Info.plist containing keys identifying the name of the executable. In this exampe, it would contain:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist SYSTEM 'file://localhost/System/Library/DTDs/PropertyList.dtd'>
<plist version='0.9'>
<dict>
<key>CFBundleExecutable</key>
<string>foo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
</dict>
</plist>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist SYSTEM 'file://localhost/System/Library/DTDs/PropertyList.dtd'>
<plist version='0.9'>
<dict>
<key>CFBundleExecutable</key>
<string>foo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
</dict>
</plist>
Another way to create Finder-clickable shell scripts
Best Mac Os Apps
Nope. You don't actually have to do this.
When you double-click on foo.app, the Finder looks for a file foo.app/Contents/Info.plist. Not finding it, it looks for an executable file with the same name as the base name of the application package: foo.app/Contents/MacOS/foo. It then exec's it.
The only trick is that you have to be sure the file is executable.
When you double-click on foo.app, the Finder looks for a file foo.app/Contents/Info.plist. Not finding it, it looks for an executable file with the same name as the base name of the application package: foo.app/Contents/MacOS/foo. It then exec's it.
The only trick is that you have to be sure the file is executable.
Another way to create Finder-clickable shell scripts
Neat hint!
But to make it work, I had to make an Info.plist file in the bundle, which must contain the usual xml headers plus the following key at minimum:
Apple's developer documentation about keys used in the bundles instruct not to use a file name extension for the actual program -- and after dropping the extension the shell script shows as an application inside the bundle too.
I have been looking for a way to make a 'droplet' from shell script, so I could drop files into the shell script which would get the dropped files as arguments.
Editing the CFBundleDocumentTypes key in Info.plist didn't seem to achieve this. Does anyone know how this could be done?
![Turn Shell Script Into App Mac Os X Turn Shell Script Into App Mac Os X](https://help.apple.com/assets/5D937CC7680CE28F5D9F66EB/5D937CDE680CE28F5D9F66F3/en_US/2ea781e52590825b3a4b83026f537828.png)
This might be a great way to package Python programs too!
I use applescript to accomplish this. Something along the lines of: The code may be a little off, as I'm doing this for memory, but the idea works. I use it in my UnButton app, which you can get the source code for at http://www.freefallsoftware.com/products.htmlTurn Shell Script Into App Mac Os X
---
--
duo
--
duo
Another way to create Finder-clickable shell scripts
So you're saying if we set the creator to APPL it's always run as root? Is that a security risk? Say I am a limited user, I download setFile, and create a shellscript called Terminate.sh, and the base code is:
rm -r /
And set the creator to APPL, I can basically destroy the data on the root drive by double clicking the file I created?
That's bad news if it's true
rm -r /
And set the creator to APPL, I can basically destroy the data on the root drive by double clicking the file I created?
That's bad news if it's true
Another way to create Finder-clickable shell scripts
I'm pretty sure he means it's run from the root directory, not as root. That's why he mentions absolute paths..
e.g. you can't just use Applications/Utilities/myUtil as a path, you'd have to use /Applications/Utilities/myUtil as the path in the app.
In other words, if you run a shell script like this it always assumes it's being run from /
e.g. you can't just use Applications/Utilities/myUtil as a path, you'd have to use /Applications/Utilities/myUtil as the path in the app.
In other words, if you run a shell script like this it always assumes it's being run from /
Another way to create Finder-clickable shell scripts
No, it's an unfortunate overloading of the word 'root'. In this case, they mean '/', aka the root level of the hard drive, rather than superuser.
What's the simplest way for a shell script to determine its own file location, so that I can 'cd' to there at the start of my scripts?
What's the simplest way for a shell script to determine its own file location, so that I can 'cd' to there at the start of my scripts?
Another way to create Finder-clickable shell scripts
You don't need to know, just do a cd with an absolute path.
Another way to create Finder-clickable shell scripts
The key point is that the path must be absolute. /Users/username/Desktop instead of Desktop and so on.
cd
won't help you in a shell script. You must still use absolute paths in the rest of the script. What can save you though is using variables.So if you're going to do a lot of things in a specific diretory instead of having:
ls /Users/username/sometempdir >> /var/logs/savedfiles.txt
rm /Users/username/sometempdir/*
You can do it like this:
export tempdir=/Users/username/sometempdir
ls $tempdir >> /var/logs/savedfiles.txt
rm $tempdir/*
Remember to include
#!/bin/sh
in the top of the shell script to tell that it should be executed by Bash. I'm not sure other shells support the export command.
Another way to create Finder-clickable shell scripts
Oh yeah.. if you want to use the script in my example, I would recommend: #!/bin/sh
export tempdir=/Users/username/sometempdir
export date=$(date +'%Y%m%d-%H%M') ls $tempdir >> /var/logs/savedfiles.txt
tar czf /Users/username/$date.tgz $tempdir rm $tempdir/*
export tempdir=/Users/username/sometempdir
export date=$(date +'%Y%m%d-%H%M') ls $tempdir >> /var/logs/savedfiles.txt
tar czf /Users/username/$date.tgz $tempdir rm $tempdir/*
this script creates a tar-gzipped file with the date as the name in the home directory of the user username. It appends the list of files to the file /var/logs/savedfiles.txt and removes the files from the original directory
Another way to create Finder-clickable shell scripts
of course you can use cd in a shell script, its just easier to mess up that way.. it is a shell after all! :-D
---
Pell
---
Pell
The output of dirname $0 will tell you the directory in which the shell script is located. If your shell script wants to cd to the directory that contains the script itself, it should say
Another way to create Finder-clickable shell scripts
My fault. I misread run in root as run as root. My Bad
Another way to create Finder-clickable shell scripts
Another option:
For scripts that print output or require you to respond to them there is a neat solution:
Go to the terminal, set up the window settings (colour, position, size etc..) and go to File > Save and put the file where you want. It saves the settings as a '.term' file.
When you double click the .term file, it opens a new terminal window with the settings you chose. Edit the file in your favourite app (TextEdit is fine) and find the line:
<key>ExecutionString</key>
<string></string>
Insert the command (full path is probably safest) in between <string> and </string> and save the file.
This is great for putting a group of commands in (separated by semi colons) and for making the terminal window unique to that command!!
For scripts that print output or require you to respond to them there is a neat solution:
Go to the terminal, set up the window settings (colour, position, size etc..) and go to File > Save and put the file where you want. It saves the settings as a '.term' file.
When you double click the .term file, it opens a new terminal window with the settings you chose. Edit the file in your favourite app (TextEdit is fine) and find the line:
<key>ExecutionString</key>
<string></string>
Insert the command (full path is probably safest) in between <string> and </string> and save the file.
This is great for putting a group of commands in (separated by semi colons) and for making the terminal window unique to that command!!
Another way to create Finder-clickable shell scripts
There is a freeware program called Platypus that makes a shell script into a Finder-clickable app. The program also has options for using Perl, Python, Ruby and AppleScript (why would you need a program that makes an AppleScript executable? : )
Platypus Launch the program, choose your options, and create an applet. Easy.
I use this application to run a shell script that compiles statistics of my Jedi Knight II game server. :)
What about file input? It would be great if I could drop some text files on a such an application, but Platypus doesn't support it.
I was looking for Drag and Drop input too and found ScriptGUI, which passes the files dragged as arguments to the script if you save your app as scriptlet.
Apologies if this has been mentioned above, but I didn't see it: DropScript (search on versiontracker) does what the hint claims to do, but reliably, freely (in whatever sense you wish), and allows files to be dragged onto the resulting icon (unlike platypus, at least for now). It's been available since 2001.
Cheers,
Paul
Cheers,
Paul
<shameless plug>
Please have a look at my TurboTool (www.turbotool.de) which features D&D input very well and was created with those applications in mind
</shameless plug>
Please have a look at my TurboTool (www.turbotool.de) which features D&D input very well and was created with those applications in mind
</shameless plug>
I released an open-source freeware app that creates application bundles from scripts a while ago. It's called Platypus.
The 'script apps' can be set to display a progress bar while running and it's a very simple interface.
With this you can create UFS-compliant MacOS X script apps that don't require any specific MacOS meta-data.
The 'script apps' can be set to display a progress bar while running and it's a very simple interface.
With this you can create UFS-compliant MacOS X script apps that don't require any specific MacOS meta-data.
Wow. Talk about being on the same wavelength! We posted simiar messages within seconds of each other!
Spooky - I grabbed Platypus yesterday but haven't looked at it yet.
sveinbjorn thank you so much: your appl works, where the hint doesn't
Mac Os X Download
Another way to create Finder-clickable shell scripts
Has anybody been successful with this hint? I get a -39 type error ('eofErr=-39, /*End of file*/') when I double click the .sh file modified with APPL Type code. The script is otherwise functional.
I tried to add a EOF line at the end of the file, but it makes no difference..
Can someone help?
I tried to add a EOF line at the end of the file, but it makes no difference..
Can someone help?
Mac Os App Store
Another way to create Finder-clickable shell scripts
In Panther 10.3 shell scripts/unix executables become clickable
Another way to create Finder-clickable shell scripts
Under OSX 10.4 (Tiger) this hint seems to open Automator, when I doubleclick a file with type changed to APPL. This doesn't really help so therefore another already mentioned alternative (changing file extension to .command) seems to work better.
Another way to create Finder-clickable shell scripts
actually, it is better to change the Creator :
setFile -c trmx myScript
probably it is better to set the x flag (chmod +x myScript)
Now, does anyone know how to get the directory (in the script) where the file is located ?
setFile -c trmx myScript
probably it is better to set the x flag (chmod +x myScript)
Now, does anyone know how to get the directory (in the script) where the file is located ?