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
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/08/28 07:46]
MartinPacker [Using Keyboard Maestro Variables]
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 16: Line 18:
 where //​[variable‗name]//​ is the name of your Keyboard Maestro Variable, but with spaces in the name replaced with underscores (`‗`). where //​[variable‗name]//​ is the name of your Keyboard Maestro Variable, but with spaces in the name replaced with underscores (`‗`).
  
-For example: ​ `File Name` would be formated ​as `$KMVAR‗File‗Name`.+For example: ​ `File Name` would be formatted ​as `$KMVAR‗File‗Name`.
  
 If your variable already has underscores,​ you can use it as is. If your variable already has underscores,​ you can use it as is.
  
 {{:​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