Thank you drl!
When I execute 'as is' it works - but it isnt quite what I was aiming for..
-> Or I fail to see how to adapt.
But I'm not getting the expected results when I modify your script to my situation:
Output:
Now here's my 'case output' , also, note the new time, isnt that great?
Allthough, this is one of the 'better' runs.
Please note the 'echo runs'!
But the $my_test_var remains empty. (just like in the modified script)
Now here's the code in question:
PHP Code:
#
# For easier code reusage, lets combine all math into a sub process
# Should help to speed things up a little more for the end user front ;)
# This seems useless... TODO remove or fix
#
if true
then
unset "${!len*}" my_test_var
swarm.geometry.update() { #
declare -g DATE_TIME=$($DATE +'%H:%M:%S') # Time on the other hand is
# If user wants extended logs, he shall have it
! $isRO && $doLogExt && init.log "$SWARM_MSG_INIT_PID_GEOMETRY: ${PPID:-$PID}"
}
export -f swarm.geometry.update
# Sub shell
(
while ${PS:-\ps} ${PPID:-$PID} | ${GREP:-\grep} ${PPID:-$PID} >> /dev/zero
do
# Ok, lets keep it simple,
#DATE_TODAY=$($DATE +'%Y.%m.%d') # Cmon, day is not THAT important
swarm.geometry.update
set -x
echo runs >/dev/zero
set +x
# Using 15 secs for fallback mode
sleep ${SWARM_INTERVALL_GEOMETRY:-15}
done
) & >> /dev/zero
SWARM_PID_THEME="$SWARM_PID_THEME $!"
fi
Please acknowledge that on first try, I had the function definition inside the subshell.
Since that didnt work out the way I wanted, I moved it 'outside' - to no change.
To me, this still looks like we cannot 'save' a variable from a sub/background process, wether it would be from within a function or not.
EDIT:
Unless I would use a tempfile to write and read the data, but that is something I want to avoid.
As I have a certain way... image... of how I want to use/show help and manpages, and how I want to handle code transparancy, I'm a bit.. focused.. on how the solution should look like.
My current expansion attempts didnt work quiet as I would have hoped.
However, to get something done, I've rearanged some and deleted some other files, as their code was now merged into functions for reusage and just a slightly more 'elegant' way how SWARM works internaly. (read: Fixed my own not-using-an-existing-variable issue)
This said, parts of status work now too.
But I still need to cross-check this with a TTY-only output, as they are (supposed to be) different - as in (translated if required) text only.
Just tried it on a TTY and... had to do some fixes... who would have thought that some shells return -bash as their $0 instead of just bash.
After that, it worked!
Though, figued I need to get rid of the underline for the title, as that becomes a 'cyan'ish background - which kinda makes it hard to read that blue text...
And sure as hell is not inteded, I mean, even adding the underline was just a little fun - and I wasnt sure wether I wanted to keep it or not.. this helps
Just thought I'd share the first image of the TTY test.
But this 'experience' is always kind of a milestone - just to know that it -as it is- works in its basic form for/in both, X and TTY/environments.
Well, once I got rid of that cyan/underline that is...
Uh finaly, I have it (printe) as I want it to behave.
A simple change - long intended, that when passing 2 strings, one is left, the other right (instead of center).
It doesnt come as easy as one might think...
Now comes the really fun part... passed string splitting...
And 'select'.
Also, if you wonder WHY (the heck) I upload so often pictures of SWARM, thats because 'just before' doing that picture, all of the 'UI' was terrible messed up.
So it's kind of: Hey it works (again), and as a reminder which build number I'd have to pick from the backups.
This said, here we go
And I just thought, it might be 'easier' to 'make': select = pick (instead of choose) and ask = yesno, because for regular user input, I'd make a function called input.
What do you think?
TODO:
Maybe even remove BOLD from title, looks a bit 'light' on TTY (hard to read : try different colors/theme first)
Find a non-tempfile using method printing different stages/index of an array (\ | / - \ | )
Fiddle my way around an 'intervall based' on UNIX seconds differences between calls from within a function without using tempfiles (alternative to the previous 'multi task' attempt)
select
edit/web/terminals
progress/bar
download
cfg.get & cfg.set
swarm configuration (general purpose *conf file handler, supports in-file-commented options for the handlers)
And these are just whats on top of my mind.
Now, allthough I have most of this "done already" - it's for TUI which was based on individual files, rather than functions - and I'm using new syntax and methods which 'dont help' to reduce 'coding time' but should help with readability and reusability of the code.
If you compare printe, well incl swarm.print.border and swarm.print.text to it's origin tui-echo, it is ALOT more readable!
However, when it was 'all file based', it was simple, all user-commands were files, and had to have args like --help and --version, but with funcions?
Sure, I could do that.
Issue is, I want it translate-able.. by which I mean, people should be able to do that 'quickly' as part of a hobby or enhusiastic week.
Thus, I only want to focus on CORE (end-user) functions (that other script authors are supposed to be using - only - I know, wont happen).
Thanks to the syntax rules I had set within my project, I could already parse current files functions and list their description (First 2 commented lines after the function definition, which as well provides the ARGS syntax, where applicable
Though, the *show function still needs some tweaking on the --text handling.
It's funny, I know how cool it is when it's done, but still I'm kind of overhelmed by the annoyance of 'reinventing the wheel' (redo what's already done).
And that is despite the fact, that I get alot done, alot quicker than I had anticipated - with alot more tweaks than it used to have.
If I had done this like 20 or 25 years ago.. oh boy this would have been THE invention of the decade. (speaking of how 'swarm' (function, aka tui-browser) will behave when all is done and works properly)
Now it's just some enthusastic old reto fanboy hobby project.
Oh geez, guess I have one of my moments, as I was just preparing some post offline, lots of text to be structured before actual posting it.
Well, while I prepared that text - regarding (my hopes for) the community-project Script-Tools, I had figured how much work there's still to do.
If I could briefly describe what swarm does, I would.
And that part I could describe in short, doesnt nearly reflect its full potential!
Once I gotten that far, I'll need to do a good video (with actual editing and voice-overs) to show at least parts of it's full power.
Because just describing is WAY too abstract, even for me reading my own text - despite knowing what I'm refering to...
Yet it's all very simple and almost obvious - at least I tried to achieve this for me.
But I'm already thinking ahead of time.
Stay focused, here and now.
Oh boy, I cant wait until I have all basics covered.
Yeah that help thing....
Since no install, no need to adjust the manpages I'd say, dont you?
So just basic --help coverage for the intended 'user'/author functions usage, sounds about right'ish, right?
Previously
Still writing and ironing out the default core display functions.
This includes reducing code that was written (at least) twice and could be 'combined' to a single function.
But mostly - as for optimizing code - I try to find a proper way around the the injection protection and 'bold' or colored strings that one might want to use/display.
At the very least so that the function title prints bold text.
The injection protection is not based on my skillset, however, I can read a case and some basic regex so I saw/knew that the console code for 'bold' causes an 'issue', which it did.
Next on my wish todolist is pick and cfg.set.
And I also need to finish bol2str in order to start with swarm.
I need to get the (basic, at least) swarm function done before the config editor - just so I can start scripting other things properly, and do 'external end-user' testing and so I can keep the code cleaner.
Also that will help to keep motivation up.
Current question...
However, for my current task at hand, the read wrappers, yesno, pick and input were, well - still are, based on the physicaly installed read I had to actualy parse the --help output of it to get its functionality to get them work poperly (for TUI).
Now for SWARM I'd like to reduce physical disk usage (files) to a minimum (for non-log actions; setting).
This and the recent Heureka that there's a builtin read, made me hope that the bash builtin read might have the same functions across all distros - as long the propper BASH version is installed, which would simplify the 'wrapping' process.... alot...
How to provide help?
Also the 'help' functionality of SWARM is slowly evolving in my head.
Main challenge here is that I want to distinct functions (for the help usage) between 'basics' and 'advanced', while keep most of it 'dynamic' to use - yet simple for translating.
Because I dont WANT to write actual help text for functions, because to get those, you would need to source SWARM and then call the function with --help, which seems 'too much' for me.
So I'd rather write/modify the (former) manpages and write a handler to work like:
So you can 'stay' in your current project but still get the information you need.
That's for now, have a nice weekend and stay healthy everyone!
My 'recent' speed increase commit, like 6 actual commits back, broke the actual creating of the user config file, which I didnt realize back then because I had forgotton to delete said file.
Next is the creating of the/a RAMDISK for RO systems, figured I dont need to copy SWARM over there, I just need to 'map' the semi-required files there.
With this said, I had lost track of the RO systems handling, allthough prepared....
Also I've copied to code to a laptop to work on that or a bit, which broke - for some weird reason - the application detection using which, allthough which is installed as well...
So, in a way, I'm back to square one again.
But that was to be expected after several years not using gnu+linux.
Gives me a chance to simplify and unify the 'init' procedure some more, hopefully
Made some basic utilites for cross-plattform usage, as well as for unified and simplified usage.
Reused and wraped RudiC's echo_, thanks again
But currently I'm still busy in re-thinking/doing the init procedure....
Well, unifying (is that a word??) the procedure of using functions to do different checks, keep/put all variables to RAM while put some essential ones (usage speed increase / customize options) in the 'rc' file.
The specific part of preparing configuration files & folders that are optional - because it must run on a Read-Only system as well, is quite more challenging than making it just in a "must-be-installed" way.
Also, with my... crazy... idea of implementing an optional ramdisk support (as root, for configuration and tempfiles only) didnt make the init procedure any easier.
Further, I need to 'bypass' the (so far hardcoded) use of /root because not all systems have it, thus I have to place the configfile (swarmrc) in another place, like using '/etc' if root has no $HOME.
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)
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)
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)
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)
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)
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)
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)
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/GenerateReport.sh:... (6 Replies)