Some time ago i was asking about python and bash performances, and i was told i could post the regarding code, and someone would kindly help to make it faster (if possible).
If you have noted, i'm on the way to finalize, finish, stable TUI - Text(ual) User Interface.
It is a framework, aiming to be of help when trying to achieve an Interface on Text level, so it is ment to be used by Scripts, to make it easier for the actual end-user.
This said, the complete package -> all required files are located at: https://github.com/sri-arjuna/tui
Note that it is most optimized for redhad based systems, if you have issues on your system, please let me know about it - and its solution, so i can fix this for others/later.
However, i already have had rewrote it in the aim for performance gain, i'll only include THAT file, representing the core-key-functions for all the presentations done within that package.
The (my) 'logic' behind this is like: printf
Print the information as required, 1 to 3 strings, left, center or right aligned, depending upon arguments, it'll get colored, and depening upon string lengths, even become multilined (not wanted, but required).
Functions are cool, but files/applications are cooler, but took me quite a while to actualy get there -> 2 years...
And i' do like to play with self-supporting-solving-scripts.
So like in most temals, printf is available, and prints on the same line until the line is full.
For my package TUI, tui-printf is the core component for all displaying tasks.
Therefor, it must not only handle several calls, while staying on the very same console line (where possible -> string lenghts), it also must provide color and newlines upon other calls, furthhermore, if the string lenghts provided are too long to be displayed on the current terminal line (whether gui-window or virtual-terminal) it must 'split' them first by arguments-locations (left,cetner,right) then by cutting the actual lenght of a single/certain string, using itself to solve this task.
As a hobby-auto-didactic-learning-kind-of-lazy-guy, i've reached the limits of my brain at this stage for this task (performance).
After this much talking, i'm still not posting the script, as you need to know HOW the script is retrieving its data....
By ENV - so most of the variables required by this TUI-package, are loaded by /etc/profile.d/tui.sh, which not only sources the systemwide configuration in /etc/tui/files, but also in the custom files within $HOME/.config/tui/*.
That way, the ENV is 'filled' with variables(19) like (but not limited to): $DONE (string: [ DONE ] in text, OR [ ✔ ] in GUI.
I'm aware that with the use of tui-status, i could also make another script, returning such similar strings, in which case, in turn, some RET_XY variables would need to be shared by env, which is penetrant within my mind, beeing aware of that, i'm open for suggestions, other than to rewrite it completly to (#)C(++), Python, or whatever.
Finaly, the script, with the most important question:
Do you see anything to increase performance?
File: tui-printf -- Actualy - please see https://github.com/sri-arjuna/tui/bl...bin/tui-printf for a readable structure....
Please understand, i've had no understand about lincenses, and still its a jungle to me.. .it'll change, i'm just not sure to what - atm...
I'm aiming to be as FOSS as possible, so i was told GPLv3 was the way to go/change?
Thank you in advance for any constructive input.
Moderator's Comments:
Tabs are maintained in CODE tags and seem to work just fine in the code shown. PHP tags have been changed to CODE tags. There are, however, lots of places where the code would be much more readable if it contained more tabs to highlight the structure of your code.
I want to make shell script that takes a list of host names on my network as command line arguments and displays whether the hosts are up or down, using the ping command to display the status of a host and a for loop to process all the host names. Im new to shell scripting so Im not quite sure... (3 Replies)
Just one question for bash shell script.
In bash script, you can use *.txt to call any files in current folder that ends with .txt, like
rm *.txt
will remove all txt file in current folder.
My question is can you actually remember or use the file name among *.txt, I know file=*.txt will not... (9 Replies)
Hi,
I want to create a script that gets a filename as an argument.
The script should generate a listing in long list format of the current directory, sorted by file size.
This list must be written to a new file by the filename given on the command line.
Can someone help me with this?
... (6 Replies)
Hey all, Im kind of lost on how to do what I want so I figured I would ask.
I want to pipe STDOUT of an app to a log file, but I want to prepend each line of that output with the date and time.
Im drawing a complete blank on how to do this?? Any ideas?
i.e.
output is currently this:... (9 Replies)
Hi,
I need to automate some repacking tasks of a boot image for Android
When in command line, I can use this command:
mkbootfs /path/to/root > /path/to/ramdisk-recovery.cpio;However, if I try to run the command from a shell script under Ubuntu, it fails and outputs to stdout instead of the... (27 Replies)
Hi All,
I need an assistance with the issue below.
I wrote big script in "bash" that automatically install an LDAP on Clients.
I'd be happy to know in order to avoid duplication of entries in files,
How i can define into the script, if the specific expressions already exist in the file, do... (7 Replies)
Hello,
I want to write a bash script to delete the content after '#'. However, if '#' appears in a string with "", ignore this. For example,
input file:
test #delete
"test #not delete"
Output file:
test
"test #not delete"
Does anyone know how to write this script?
Thanks (1 Reply)
I am trying to look through one of my directories to remove certain files. I am pretty new to Unix and bash so I just need a little help in starting this. I know I would have to write two loops one to iterate the directories and one to iterate the files. How would I write the loops? (3 Replies)
Hello,
For several of our scripts we are using awk to search patterns in files with data from other files. This works almost perfectly except that it takes ages to run on larger files. I am wondering if there is a way to speed up this process or have something else that is quicker with the... (15 Replies)