Automator: current directory in shell script not accepted
Hi! Guys on SnowLeopard forum told me to write here.
I wrote a bash script requiring first the directory where the script is.
The script runs fine itself. I want to integrate this as an Automator's service, right-clicking on random image and starting the script in THAT directory.
Unfortunately, cd "`dirname "$0"`" doesn't seem to work when built in automator and Home directory is always default.
I also tried in automator with this http://img84.imageshack.us/img84/9317/schermata20100605a00251.png (sorry it's italian,below a translation)
Folders in Finder
1)Obtain specified items from Finder: Path
2)Shell script
I was told to add the 2nd line with "export..." because convert command is not recognized in shell script inside automator. However, it fails too (only work in Home directory)
All solutions will be appreciated
Thanks
Stefano
I wrote a bash script requiring first the directory where the script is.
#!/bin/bash
cd "`dirname "$0"`"
convert *_A.jpg *_N21.jpg *_I3.jpg -background black -compose screen -flatten merge.jpg
exit
The script runs fine itself. I want to integrate this as an Automator's service, right-clicking on random image and starting the script in THAT directory.
Unfortunately, cd "`dirname "$0"`" doesn't seem to work when built in automator and Home directory is always default.
I also tried in automator with this http://img84.imageshack.us/img84/9317/schermata20100605a00251.png (sorry it's italian,below a translation)
Folders in Finder
1)Obtain specified items from Finder: Path
2)Shell script
#!/bin/bash
export PATH=$PATH:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/X11/bin
cd $@
convert *_A.jpg *_N21.jpg *_I3.jpg -background black -compose screen -flatten merge.jpg
exit
I was told to add the 2nd line with "export..." because convert command is not recognized in shell script inside automator. However, it fails too (only work in Home directory)
All solutions will be appreciated
Thanks
Stefano
MacBook Pro 2010, Mac OS X (10.6.3)