hi guys
I have 3 pkgs in a folder and i wondered if it is possible to install them via the command line with a for statement.
does anyone know if this is possible and how to do this?
Thanks
hi guys
I have 3 pkgs in a folder and i wondered if it is possible to install them via the command line with a for statement.
does anyone know if this is possible and how to do this?
Thanks
The below is a snippet from a script I I had put together to find any pkgs or mpkgs in a set folder and install them with a while loop (not a for loop), and also move the completed package to another folder if the install was successful (so it wouldn't keep trying to install it over and over again) or just exit if it encounter and error.
You'd have to set your variables for the $PathtoPKG and $DoneF (done folder), but this worked OK for me in testing.
find "$PathtoPKG" -maxdepth 1 -name *.mpkg -or -name *.pkg | while read file; do
/usr/sbin/installer -pkg "$file" -allow -target /
## If install was successful, move the package to a done folder
if [[ $? == 0 ]]; then
sleep 2
mv "$file" "$DoneF"
## If install failed, exit out of the script (You could also have it skip that install and move on to the next)
else echo "Installation for $file failed"
exit 1
fi
done
thanks very much that is great
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.