Skip to content

Request: context as shell environment variable #316

Closed
dfaulkner opened this Issue Feb 11, 2014 · 2 comments

2 participants

@dfaulkner

It would be nice to have an environment variable that contains the string value of the current context that's accessible during shell script execution. Currently it's necessary to make each shell script execution unique by passing the context label as an argument in the shell script parameter. Instead, scripts could simply reference the appropriate variable, such as $CONTROLPLANE_CONTEXT, or similar.

@dustinrue
Owner

Put this in your .bash_profile and then scripts can call the function to get the current CP context or in some other file that you can "include" in your scripts.

function current_context {
   osascript -e 'tell application "ControlPlane"' -e 'get current context' -e 'end tell'
}

Then in some other script you can do the following:

#!/bin/bash

# source the file you placed the function in
source ~/.bash_profile

if [ "$(current_context)" == "VPN Connected" ]; then
  echo "The vpn is connected"
fi
@dustinrue dustinrue closed this Feb 12, 2014
@dfaulkner

Just what I was looking for. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.