Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.


macrumors member
Original poster
Oct 12, 2015

Looking for help on setting up a variable properly within a bash script. My goal is to install a printer driver by calling the lpadmin command from within an AppleScript (.app). I am trying to point the variable '$dir' to the same location as the script. I placed the name of the driver at the end of the variable command since I cant seem to figure out the syntax. Here is what I got so far:

dir=(cd -P -- "$(dirname -- "$0")" && pwd -P ) CNMCIRAC5250S2.ppd.gz

lpadmin -p $SysPrinter1 -v $Addr1 -D $DispPrinter1 -L $Bldg1 -m $dir -E -o printer-is-shared=false


macrumors 68000
Apr 19, 2004
I don't have a lot of experience with AppleScript but it sounds like you are trying to do something similar to what I did for a small Automator utility I wrote.

In my case I happen to have a java cli program that I wanted to run with an input file chosen by the user and I wanted this to work as a simple drag and drop utility.

I had the java jar embedded within the .app folder. In my Automator program I had two steps. An AppleScript step and a bash script step. The output of the AppleScript step is sort of piped into as input to the bash script step.

I used the POSIX path to get the unix style paths of an input file that the user dragged and dropped onto my utility. I also get the "path to me" to which is the path to automator utility. I use this as reference to then call my embedded jar file in the bash step.

Run Apple Script step
on run {input, parameters}
    set workflowPath to POSIX path of (path to me)
    set pathOfInputFile to POSIX path of (input)
    return {workflowPath, pathOfInputFile}
end run

Run Shell Script step

java -jar ${workflowPath}/Contents/Java/my.jar ${pathOfInputFile};
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.