Bash Scripting on the Mac – Installing Flash

email me

This can be used to install the Flash Player. You will need the Flash pkg file located in the DMG.

#!/bin/sh

mytitle="Flash Setup"
echo -e "\033]2;$mytitle\007"

# Start
clear
MSG1="Mac User!"
echo "Hello, $MSG1"
sleep 5 # "sleep" for 5 seconds

clear
MSG2="This is the setup for Flash."
echo "$MSG2"
sleep 5 # "sleep" for 5 seconds

## clear
## MSG3="Mounting DMG..."
## echo "$MSG3"
## sleep 5 # "sleep" for 5 seconds

# # Change directory to desktop
cd ~/Desktop
pwd
sleep 5 # "sleep" for 5 seconds
## hdiutil mount flash.dmg

clear
MSG4="Installing Flash..."
echo "$MSG4"
sleep 5 # "sleep" for 5 seconds
## sudo -i installer -pkg "flash.pkg" -target "/"
echo "Pa55W0rd" | sudo -S -k installer -pkg "/Users/UserName/Desktop/flash.pkg" -target "/"

clear
MSG5="Flash was successfully installed!"
echo "$MSG5"
sleep 5

clear
MSG6="Unmounting DMG..."
echo "$MSG6"
sleep 5 # "sleep" for 5 seconds
cd ~
hdiutil unmount "/Volumes/Flash/"

osascript -e 'tell application "Terminal" to close (every window whose name contains "Flash")' & exit

 

Notes

Turn your script into an executable script

chmod +x YourScript

 

The below will safely pipe your password to the sudo command, without retaining a history of your password.

echo “your_password” | sudo -S -k

“-S”, means to use stdin for the password,

“-k” means to ignore cached credentials to force sudo to always ask. This is for consistent behavior.

 

This method does work on older and new versions sudo:

$ echo “your_password” | sudo -S -v

 

Turn your scripts into .app files using Platypus: http://eddiejackson.net/wp/?p=8493

There are several ways to convert shell scripts into applications. Platypus offers the most customization and options in a GUI, Appify is the quickest way to create one from the command line, and SetFile is a good solution for your own personal use (not intending to distribute). Now, if you plan on deploying packages using desktop management software, I recommend looking into Iceberg or using Apple’s Packages app.

 

tags: executable, run script, bash command, .command, .sh, MrNetTek