From 989c858e808075868df0aa1dfafc1256f0dc3eec Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Fri, 14 Mar 2025 23:33:33 +0000 Subject: [PATCH] working with env vars;rewriting my personal shell scripts --- projects/oorexx/envvars.rex | 53 +++++++++++++++++++++++++++++++++++++ projects/oorexx/memo.rex | 13 +++++++++ projects/oorexx/wx.rex | 4 +++ 3 files changed, 70 insertions(+) create mode 100755 projects/oorexx/envvars.rex create mode 100755 projects/oorexx/memo.rex create mode 100755 projects/oorexx/wx.rex diff --git a/projects/oorexx/envvars.rex b/projects/oorexx/envvars.rex new file mode 100755 index 0000000..7e31b57 --- /dev/null +++ b/projects/oorexx/envvars.rex @@ -0,0 +1,53 @@ +#!/usr/bin/env rexx + +parse source os . +if os~startsWith("Win") then command='set' +else command='env | sort -f' + +say "operating system: "os', command was: "'command'"' +Say "---" +call env_with_array +Say "---" +call env_with_stem + +Exit + +env_with_array: + Say "Getting Environment Vars Using Array:" + vars=.array~new + address system command with output using (vars) + len=vars~items~length + say "Number of env vars: "||vars~items + + if rc=0 then + do counter i var over vars + select + when var~startsWith("PWD") then parse var var . "=" pwd + when var~startsWith("HOME") then parse var var . "=" home + when var~startsWith("SHELL") then parse var var . "=" shell + otherwise nop + end /* select */ + end + say home + say pwd + say shell + +Return + +env_with_stem: + Say "Getting Environment Vars Using STEM: " + address system command with output stem env. + say "Number of env vars: "||env.0 + + Do i = 1 to env.0 + select + when env.i~startsWith("PWD") then parse var env.i . "=" pwd + when env.i~startsWith("HOME") then parse var env.i . "=" home + when env.i~startsWith("SHELL") then parse var env.i . "=" shell + otherwise nop + end/* select*/ + End + say home + say pwd + say shell +Return \ No newline at end of file diff --git a/projects/oorexx/memo.rex b/projects/oorexx/memo.rex new file mode 100755 index 0000000..252dc2f --- /dev/null +++ b/projects/oorexx/memo.rex @@ -0,0 +1,13 @@ +#!/usr/bin/env rexx +address system "echo $HOME" with output stem home. + +parse arg note +if note \= "" then note = changestr(" ",note,"_") +else note = "text_memo" + +filename=home.1, + ||"/Documents/memos/", + ||changestr("-",date("I"),"")||"_", + ||changestr(":",time(),"")||"_"||note||".md" + +address system "tilde "||filename diff --git a/projects/oorexx/wx.rex b/projects/oorexx/wx.rex new file mode 100755 index 0000000..e0a8bd4 --- /dev/null +++ b/projects/oorexx/wx.rex @@ -0,0 +1,4 @@ +#!/usr/bin/env rexx +parse arg loc +if loc = "" then loc="Cowley,UK" +Address system "ansiweather -l "||loc||" -u imperial -s true -i false -a true"