i have a small script that runs a jar file :
#!/bin/bash prefix="foo"; name=`ls ${prefix}*.jar`; echo $name; java -jar $name prop1.properties prop2.properties when i run it in the terminal using ./myscript.sh, it works fine and the jar file executes, but when i rename it in myscript.command and double click it, i have this error :
ls: foo*.jar : No such file or directory I saw that apparently a .command file opens a terminal at the root directory, so I tried finding the directory containing myscript.command using that :
dir = 'find <dir> -maxdepth 1 -type d -name '*myDirContainingJar*' -print -quit' cd $dir but dir is just blank, any ideas ???
dir = ...command won't work for 3 reasons: 1) The spaces around the=mean the shell won't treat it as an assignment (it's treated as thedircommand, with=as its first argument). 2) The single-quotes around thefindcommand mean it'll be treated as a string rather than a command; you want backquotes or$( )(with$( )being the preferred option). And 3) there may be more than one directory matching the pattern, and it won't reliably pick the right one.