-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathURL Open.sh
More file actions
51 lines (40 loc) · 1.39 KB
/
URL Open.sh
File metadata and controls
51 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
####################################################################################################
#
# ABOUT
#
# Open the URL specified in Parameter 4
#
####################################################################################################
#
# HISTORY
#
# Version 1.0, 11-Mar-2016, Dan K. Snelson
# Original version
# Version 1.1, 18-Oct-2016, Dan K. Snelson
# Added parameter to specify which browser opens a given URL
#
####################################################################################################
### Variables
url="${4}" # URL to open
browser="${5}" # Browser to open URL
loggedInUser=$(/usr/bin/stat -f%Su /dev/console) # Currently loggged-in user
# Ensure Parameter 4 is not blank ...
if [ "${url}" == "" ]; then
echo "Error: Parameter 4 is blank; please specify a URL to open. Exiting ..."
exit 1
fi
if [ "${browser}" == "" ]; then
echo "* Preferred browser not specified; using Safari ..."
browser="Safari"
fi
case ${browser} in
Chrome ) browserPath="/Applications/Google\ Chrome.app/" ;;
Firefox ) browserPath="/Applications/Firefox.app/" ;;
Safari ) browserPath="/Applications/Safari.app/" ;;
* ) browserPath="/Applications/Safari.app/" ;;
esac
echo "#### Open URL ####"
/usr/bin/su - $loggedInUser -c "/usr/bin/open -a ${browserPath} ${url}"
echo "Opened: ${url} with ${browserPath}"
exit 0