Jump to content
TingTingBen

How to run script from /usr/local/bin?

Recommended Posts

Hi everyone!

 

For long, I've been launching VirtualBox's virtual machines with the following script, bin/bash being the language selected:

VBoxManage startvm "vm_name"

In a recent update, it seems that VirtualBox moved the necessary "files" (I don't really know/understand what happens in the background) from /usr/bin to /usr/local/bin. See this topic: https://forums.virtualbox.org/viewtopic.php?f=8&t=68825. People there pointed that it might be related to recent security restrictions in OS X (Yosemite, El Capitan).

 

From the Terminal, when I first point to /usr/local/bin, the previous piece of code works perfectly. So my question is, how can I point to that special directory from a Run script window of a workflow?

 

Ultimately, should Alfred be updated to offer /usr/local/bin in the Language list?

 

Thanks for your help!

Share this post


Link to post

/usr/local/bin is not a language (neither is /bin or /usr/bin). They're directories.
 
Your environment has a variable called PATH, which is a list of directories. When a program (or a shell) wants to run another program, it can simply call it by name (e.g. VBoxManage) provided it is in one of the directories in PATH.
 
Alfred's PATH is the default one of /bin and /usr/bin, so any program in either of those directories can be called by name.
 
If you want to run a program in /usr/local/bin, you have to call it by its full path, e.g. /usr/local/bin/VBoxManage.
 
So, instead of running VBoxManage startvm "vm_name" you just need to run:

/usr/local/bin/VBoxManage startvm "vm_name"

Share this post


Link to post

 

/usr/local/bin is not a language (neither is /bin or /usr/bin). They're directories.

 

Your environment has a variable called PATH, which is a list of directories. When a program (or a shell) wants to run another program, it can simply call it by name (e.g. VBoxManage) provided it is in one of the directories in PATH.

 

Alfred's PATH is the default one of /bin and /usr/bin, so any program in either of those directories can be called by name.

 

If you want to run a program in /usr/local/bin, you have to call it by its full path, e.g. /usr/local/bin/VBoxManage.

 

So, instead of running VBoxManage startvm "vm_name" you just need to run:

/usr/local/bin/VBoxManage startvm "vm_name"

 

Thank you very much @deanishe for the explanations and the solution you provided, that makes sense and works perfectly!

Share this post


Link to post

Just to expand a bit on deanishe’s (as always excellent) answer, in addition to providing the full path to the executable, you may also expand your PATH in your Alfred script.
 
What I mean is: instead of using /usr/local/bin/program_name repeatedly for every one of them, if you know they are all inside /usr/local/bin you may start your script with the line PATH=/usr/local/bin:$PATH (directories in PATH are separated by :, and calling it like in this example means your already existing PATH will be appended to your additions).
 
What this allows you is to call program_name (without the full path), for the continued duration of the script.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...