How to install .dmg using shell script

I want to write a script to install an application using .dmg file.
.dmg file already exists in the folder.

working on MAC OS.

Command Line Mac: Installing a .dmg application from the command line

https://discussions.apple.com/thread/948551?start=0&tstart=0

1 Like

hey itkamaraj thanks for all the help..

i need some more help :confused:

Actually now i am trying to so something like this:]

awk -v new="3.1.0.5" -F"[<>]" '/CFBundleVersion/ {getline;current=$3;exit}END{if(new>current){
print "NOT OK"
hdiutil mount AdobeAIR.dmg
#sudo cp -R "/Volumes/AdobeAIR of the AdobeAIR/ of the AdobeAIR.app" /Applicatio#ns
}else{
print "OK"
}}' Info.plist

:wall:

For which i am getting following error:

awk: syntax error at source line 3
context is
hdiutil mount >>> AdobeAIR. <<< dmg
awk: illegal statement at source line 4

HELP!

Hi, awk is not a shell, so it complains about hdiutil...

1 Like

execute the awk command alone. and store the result ( "OK" or "NOT OK" ) in a variable.

Then use if condition to check the variable value and do the installation

1 Like

:frowning:

awk -v new="3.1.0.5" -F"[<>]" '/CFBundleVersion/ {getline;current=$3;exit}END{if(new>current){result="NOT OK"}else{result="OK"}}' Info.plist
echo $result

output is Nothing: BLANK

seems i don't know anything about shell scripts :smiley:

and ya i tried:

$ hdiutil mount AdobeAIR.dmg

OUTPUT:
/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_HFS /Volumes/Adobe AIR

After this how should I copy? following is not working:

$ sudo cp -R "/Volumes/Adobe AIR of the Adobe AIR/ of the AdobeAIR.app" /Applications

Error:
cp: /Volumes/Adobe AIR of the Adobe AIR/ of the AdobeAIR.app: No such file or directory

result=$(awk -v new="3.1.0.5" -F"[<>]" '/CFBundleVersion/ {getline;current=$3;exit}END{if(new>current){print "NOT OK"}else{print "OK"}}' Info.plist)
echo $result

:frowning:

result=$(awk -v new="3.1.0.5" -F"[<>]" '/CFBundleVersion/ {getline;current=$3;exit}END{if(new>current){print "NOT OK"}else{print "OK"}}' Info.plist)
echo $result
var="NOT OK"
if["$result"="NOT OK"];then
 echo "INSTALL"
else
 echo "NO INSTALL"
fi

error:
install.sh: line 4: syntax error near unexpected token `then'
install.sh: line 4: `if["$result"="NOT OK"];then'

---------- Post updated at 06:40 AM ---------- Previous update was at 06:37 AM ----------

And i am still struggling with: :wall:

$ hdiutil mount AdobeAIR.dmg

OUTPUT:
/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_HFS /Volumes/Adobe AIR

After this how should I copy? following is not working:

$ sudo cp -R "/Volumes/Adobe AIR/Adobe AIR Installer.app" /Applications

So there is no error now, it asks for the password then it copies the .app file to applications folder
THE APPLICATION IS NOT INSTALLED!!

# suggestion

result=$(awk -v new="3.1.0.5" -F"[<>]" '/CFBundleVersion/ {getline;current=$3;exit}END{if(new>current){print "NOT OK"}else{print "OK"}}' /absolute/path/to/application_name.app/Contents/Info.plist)

#note the spacing 

if [ "$result" == "NOT OK" ]; then
echo "INSTALL"
else
echo "NO INSTALL"
fi