Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Global Timer Variable

Global Timer Variable

Global Timer Variable

Trying to do something I thought would be real simple ... basically looking to have a Counter that resides on a PI Raspbian (unix) that could be Cleared, Set, Run and monitored from a node-red client ... this timer is required to control a relay ... on during count and off when 0 ... this is easy enough to do if the client is the keeper of the Counter ... except that if the client disconnects, the counter and relay are in limbo ... the trick would be to initiate a counter and have it run completely on the PI ... with the ability to view the current timer count from any client.

Started out with Python thinking incorrectly that if I define an include with a global and maintain a program in a loop that contains that global then run another instance with the same global that they would somehow be connected ... STRIKE 1

Decided to attempt to use an ENV from Python ... STRIKE 2

Then proceeded to try using a Shell Script ... STRIKE 3

OLD FORGOTTEN FACTOID: ENV vars, even when exported, only affect the current "COPY" of the ENV for the current instance of a shell

Brain damage from old age? ... after redetermining this recollection from another lifetime, AND, more specifically that there is a way to force a script to run in the root shell ( . /<path>/<somescript>.sh) ... while this does work locally, I can't seem to get this to work from a node-red execute node

Took this one step further and created an executable that contained the explicit command by itself

CODE -->

. /<path>/<script>.sh $1 

But when called this appears to still run in another shell so fails ... I think the "." doesn't explicitly force the script to run in the root shell it appears to be relative to the shell that is calling the script

The node-red Exec Node has both a command and a param entry ... I have tried using "." as the command or . /<path>/<script>.sh neither work

Is there some other way, other than using a File and or an SQL record that might provide a way to maintain a variable that won't lose scope and or die?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close