Automator Folder Action with Shell Script. How do I load the user's environment.

10 views
Skip to first unread message

Tobias

unread,
Nov 9, 2013, 6:57:40 PM11/9/13
to cocoahead...@googlegroups.com
Hey RVA CocoaHeads,

Is the RVA CocoaHeads group still alive? I'm posting this questions, hoping to get a grunt of life.

I have an Automator Folder Action that optimizes each added image, using image_optim
The folder action does this by running a shell script that calls the image_optim executable. 
Since the executable is from a ruby gem and I use rbenv, I have to load my .bashrc file where my rbenv and other things get setup. 
That's simple:

source $HOME/.bashrc

I would like, however, to give this folder action to other folks for use,
So I'm looking for a general method to make that the shell script had done whatever setup terminal does when it opens a new shell.
I believe it runs the /usr/bin/login.

Two Questions:
  1. Can anyone link me to tell me a good tutorial / reference / explanation about what occurs when a new terminal window is opened on OS X?
  2. What is the best way of making sure that the shell script which runs in the folder action, setups the environment correctly?

I've attached the workflow and the shell script embedded in the workflow. 
I'm no bash expert, so please let me know if I could improve the script.

-Tobias

image_optim_folder_action.zip
Reply all
Reply to author
Forward
0 new messages