Passing environmental variables to scripts

Posted on
Thu Jan 13, 2022 6:22 pm
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Passing environmental variables to scripts

I don't know Python nor AppleScript but with the very little I know about it I managed to do what I need to do in bash--which actually calls a tiny Python script I wrote, but just barely. Using the Store result in variable checkbox and the pwd command I found out the very long path scripts run from, but things still didn't quite work, in another lucky guess it occurred to me to redirect printenv to a file where I learned that none of the environmental variables of the user running the server are there.

I sort of need to pass one variable or else I have to do a lot of editing. I don't care if it doesn't match the user's environment, as long as there's one place to put it.

The output I got from printenv is:
Code: Select all
zx5:~ v$ cat exportedenvironment
__CF_USER_TEXT_ENCODING=0x3DA3EE0D:0x0:0x52
PWD=/Library/Application Support/Perceptive Automation/Indigo 7/Plugins/.Action Collection.indigoPlugin/Contents/Server Plugin
SHLVL=1
_=/usr/bin/printenv
zx5:~ v$


That's not randomly generated, is it? If not, where is it set?? I'm out of lucky guesses, I have a feeling there might be something in Action Collection.indigoPlugin because of the following /Contents/ (it reminds me of .apps) but while I break my installation exploring that I thought I should ask for help so I break it just in time to be too late. :)

I'll bet you think this post is about you. Don't you. ♪

Posted on
Thu Jan 13, 2022 9:15 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Passing environmental variables to scripts

Shell environment variables aren't going to be available to scripts without some work. But, why would you want to use a shell variable? If you use an Indigo variable to hold the value, then your scripts can just reference the Indigo variable.

It's probably best to fully describe what it is you are trying to do - there's likely a better approach to whatever you are trying to do, but it's hard to know without a full description.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jan 16, 2022 5:00 pm
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Passing environmental variables to scripts

Thanks for answering :)

First I'm trying to familiarize myself with the whole thing to get things done in bash until I have time to learn a little more Python.

Redirecting the output to a file (and viewing it live in Console.app) I tried printing Indigo variables using the echo and printf commands, (double-)quoted and unquoted, by varName and varId, with $ and without it, none worked. Then, just moments ago actually, it occurred to me that I could use source to get my .bash_profile or another of these and just now I'm thinking I don't need to get those files at all bc I can just make up a new one with the things I need and all of the files I already created (plus their Action Groups) will work as they are. :D

As for my goal, it's nothing fancy, small things like multilingual text-to-speech, playing random sounds*, running tasks on other systems or calling APIs. These things are trivial to perform in bash but using the GUI either take way too many steps that it takes a another script to remember them or just can't be done, even Indigo's API I've called a few times from bash so I know I can circle things around from there if need be which isn't true for Python/AppleScript. I'm not trying to learn a scripting language either, I'll have at some point but for now that's what Indigo what I got Indigo for.

Thanks again !

* : this is my one Python script, BTW--probably replaceable with bash + VLC in daemon

I'll bet you think this post is about you. Don't you. ♪

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests