User Tools

Site Tools


action:Execute_a_Shell_Script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
action:Execute_a_Shell_Script [2018/04/13 16:48]
JMichaelTX [Path in Shell Scripts]
action:Execute_a_Shell_Script [2018/06/05 12:22]
JMichaelTX ADD section on Python
Line 11: Line 11:
  
 ==== Using Keyboard Maestro Variables ==== ==== Using Keyboard Maestro Variables ====
 +
 +=== Most Languages like bash, perl, ruby ===
  
 In your script, use this format: ​ `$KMVAR_[variable_name]` In your script, use this format: ​ `$KMVAR_[variable_name]`
Line 21: Line 23:
  
 {{:​action:​km7-shell-script.png?​nolink|}} {{:​action:​km7-shell-script.png?​nolink|}}
 +
 +=== Python ===
 +
 +Accessing Keyboard Maestro Variables in Python is somewhat different. ​ Here is an example:
 +
 +```python
 +#​!/​usr/​bin/​env python
 +import os
 +print os.environ['​KMVAR_local_DataStr'​].count(os.environ['​KMVAR_local_CharToCount'​])
 +```
 +
 +See the [[#​Forum|Forum]] section below for more Python examples.
 +
 +---
  
 Note that you can only read these environment variables. ​ You cannot write to them (or more accurately, you can write to them but that will not change the Keyboard Maestro variables that they were created from). Note that you can only read these environment variables. ​ You cannot write to them (or more accurately, you can write to them but that will not change the Keyboard Maestro variables that they were created from).
action/Execute_a_Shell_Script.txt ยท Last modified: 2023/09/22 04:39 by peternlewis