Visit Our UNIX and Linux User Community

Top Forums Shell Programming and Scripting Blog-Thread: Creating a Shell Wrapper and Runtime Modifier (SWARM) Post 303045069 by sea on Wednesday 11th of March 2020 12:31:39 PM
Old 03-11-2020
Blog-Thread: Creating a Shell Wrapper and Runtime Modifier (SWARM)

SWARM = Shell Wrapper and Runtime Modifier

But as a matter of fact, it's more like a Text User Interface framework for scripts.
Which was the original title (TUI) of the first split-up iteration from Script-Tools.

Script-Tools is still the 'end/final-project', SWARM is just the way to get there.
And for that project - Script Tools - I'd like to ask to cooperate with others, once SWARM is stable that is.

I've had it (Script-Tools) working with things like: st tweak grub 2 theme or st dev ssh con or even st set lm gdm rndbg.
As you see by the command syntax, it has several sub section, all of which are directories containing directories and files which can be called and arguments/options passed to.

This (functionality of SWARM) allows one to 'sort' one's script into directories and still be able to call them directly.
I belive this is something alot of us want.

Further, I love the console, it's very powerfull, but... also boring in it's appearance.
There's alot of unused space as everything is left oriented, SWARM offers you to output text left, center or right oriented.
And even better yet, it allows for 2 different 'liners' called 'header' and 'title' which bring some (theme'able) colors and designs to the regular terminal.

SWARM also offers 'handlers' for browsers and editors (and more), for both, CLI and GUI applications alike.
So you, as a script author/writer dont have to worry which text editor an enduser has installed.
Further it simplifies repeative tasks like yes/no question and status information wether or not a task has been successfully executed (yesno "question", status $? "text").

So, in an all short saying:
SWARM allows you to easy write application-like scripts.

A comment from a GNU guy i've sent TUI/SWARM to review, sorry lost the email and dont recall the name:
"A very new approach to the console!"

For general feedback, please refer this specific thread:
Feedback wanted for upcoming script language
But of course if we can keep it short, you're welcome to post here too, but I dont want hughe discussions in this thread.

If this sounds interesting to you so far, and if you want to know what kind of challenges I'll be facing, stay tuned Smilie
But a warning, I've completed all tasks already, what I need to do now is to restructure and rewrite/adjust the code for the new projectname SWARM (runtime only, no install required anymore).

What I want to do in/with this thread:
* Write my 'todays goal'
* Write how it went, because it's been 5 years when I last 'viewed' my code.
* This is to push myself, because redoing what you've already done is.. annoying...

--- Post updated at 19:31 ---

Yesterday I finaly completed the basic loading procedure.
Had an issue with traps, due to blindly copy-paste code without considering from where I copied (a file generating script, thus some variables were escaped, which obviously didnt work in an executed/sourced file).

Traps aside, the Theme procedure works now, at least the Theme-Array contained the required data.

And I learned something new.
If you want to fill a variable/array from a function for the main script, use declare -G varname[=value]

Also some other interesting point, the main reasons I initial had decided to go for an installation was that not all Distro's support "COLUMNS" or "LINES", thus when setting those variables per call, they wouldnt update in a runtime only apporach, but when beeing single files each call will have the updated values, so the aligment of the output is according to the terminal windows dimensions (if called in a GUI).
Now, I do have some more experiences, so it wasnt a problem to simply make it a subshell (is that the proper word?) which will reset those 2 values and export them to the mainscript.

Heck, I've even gave it an option to set the intervall.
Writing this reminds me of something, this value should be 'set'able' from the outside so a script can define how fast the values COLUMS and LINES are beeing updated.
Maybe even a check wether we're in GUI or not.. as for a console (TTY) only, those values wont change, so the intervall could be disabled alltogether...

(this is precicly why I wanted a blog, writing about something helps to find new things, and share new discoveries/learned things)

So much for yesterday.
Today I want to get swarm.print.border done (all swarm.* functions are for internal use only, bash'ism), maybe even the basic printl function.
But boy.... thats 500 lines of code (1 function) to review and adjust, wish me luck Smilie
These 4 Users Gave Thanks to sea For This Post:
Test Your Knowledge in Computers #575
Difficulty: Medium
If a program has poor memory management and fails to deallocate memory when it is no longer needed, the memory will not leak.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

korn shell version at runtime?

How can I check what kornshell version I am using at runtime from within a kornshell script? (3 Replies)
Discussion started by: qanda
3 Replies

2. Shell Programming and Scripting

crontab is not creating runtime files which are in script..

this is the output i am getting here.. cp: cannot create /wls_domains/eoigw/eoigwsA/deliv/cron/MailingScript/eoigwsA_Health_Status_Report.html: Permission denied /wls_domains/eoigw/eoigwsA/deliv/cron/MailingScript/ /wls_domains/eoigw/eoigwsA/deliv/cron/MailingScript/ (6 Replies)
Discussion started by: surekha268
6 Replies

3. Shell Programming and Scripting

Korn Shell Wrapper script

Hi Guys, I am trying write a wrapper script but I don't have any idea. I have 4 different korn shell scripts and all of them needs some parameters from command line (positional parameter). My script cant be interactive because its supposed to be automated. I am confused how can I write a wrapper... (6 Replies)
Discussion started by: pareshan
6 Replies

4. Web Development

Creating a blog site on a local computer

Hello! I would like to create a blog website on a web domain of mine. The blog will be used for publishing economics-lated articles. I tried to use a few open source packages for blog creation (WorldPress, b2evolution, Movable type) which I wanted to test on a local computer before arranging... (5 Replies)
Discussion started by: degoor
5 Replies

5. Programming

creating multiple threads using single thread id

Hi all, Can I create multiple threads using single thread_id like pthread_t thread_id; pthread_create(&thread_id, NULL, &print_xs, NULL); pthread_create(&thread_id, NULL, &print_ys, NULL); pthread_create(&thread_id, NULL, &print_zs, NULL); pthread_join(thread_id, NULL); what... (2 Replies)
Discussion started by: zing_foru
2 Replies

6. Shell Programming and Scripting

Shell Runtime Statistics

Hi, I am trying to capture runtime stats of a shell script (c shell). Are there system variables to call? Or should I create a date variable at the start of the script and at the end of the script? I am trying to capture the time if the script stops or ends with error. Please help. ... (4 Replies)
Discussion started by: CKT_newbie88
4 Replies

7. Shell Programming and Scripting

Wrapper Script in Perl Or shell

Hello, My requirement is based on Oracle where we run a perl script and it asked some questions.I want to write a wrapper which will answer all these questions. How is it possible. Thanks (16 Replies)
Discussion started by: cotton
16 Replies

8. Homework & Coursework Questions

Shell Script average runtime

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Make a bash script that calculates average runtime for the first two scripts you made. The average should be... (17 Replies)
Discussion started by: navlelo
17 Replies

9. Shell Programming and Scripting

Shell Script and Progress Bar or GUI Wrapper

Hi, I have shell script that I am running under Ubuntu as root. Is it possible to hide the command window and show the user some sort of progress /random progress bar / or other form of GUI interaction? On MAC, I have been using Platypus but on Ubuntu I am not sure what to do. (4 Replies)
Discussion started by: naveedanwar4u
4 Replies

Featured Tech Videos

All times are GMT -4. The time now is 06:10 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy