How to read plist information (bundle id) from a shell script

The defaults command can read/write to any plist file, just give it a path minus the .plist extension: $ defaults read /Applications/Preview.app/Contents/Info CFBundleIdentifier com.apple.Preview This pulls the CFBundleIdentifier value directly from the application bundle’s Info.plist file. Defaults also works with binary plists without any extra steps.

How to pass in parameters to a SQL Server script called with sqlcmd?

Use the -v switch to pass in variables. sqlcmd -v varMDF=”C:\dev\SAMPLE.mdf” varLDF=”C:\dev\SAMPLE_log.ldf” Then in your script file CREATE DATABASE [SAMPLE] ON PRIMARY ( NAME = N’SAMPLE’, FILENAME = N’$(varMDF)’ , SIZE = 23552KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N’SAMPLE_log’, FILENAME = N’$(varLDF)’ , SIZE = 29504KB , … Read more

how to make bash expand wildcards in variables?

A deleted answer was on the right track. A slight modification to your attempt: shopt -s extglob MYDIR=”./images” OTHERDIR=”./images/junk” SUFFIXES=’@(pdf|eps|jpg|svg)’ mv “$MYDIR/”*.$SUFFIXES “$OTHERDIR/” Brace expansion is done before variable expansion, but variable expansion is done before pathname expansion. So the braces are still braces when the variable is expanded in your original, but when the … Read more

How to iterate over an array using indirect reference?

${!ARRAYNAME[@]} means “the indices of ARRAYNAME“. As stated in the bash man page since ARRAYNAME is set, but as a string, not an array, it returns 0. Here’s a solution using eval. #!/usr/bin/env bash ARRAYNAME=’FRUITS’ FRUITS=( APPLE BANANA ORANGE ) eval array=\( \${${ARRAYNAME}[@]} \) for fruit in “${array[@]}”; do echo ${fruit} done What you were … Read more

Shell scripting: die on any error

With standard sh and bash, you can set -e It will $ help set … -e Exit immediately if a command exits with a non-zero status. It also works (from what I could gather) with zsh. It also should work for any Bourne shell descendant. With csh/tcsh, you have to launch your script with #!/bin/csh … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)