The config file is written properly now (again).
For some reason (order), I had an issue to properly identify curl/wget and more/less, for the latter it used the fallback value 'cat'- while both, less and more were installed.. OMG...
Well, it all (that part) works now again as expected.
What currently confuses me, that it DOES print output (text), but neither swarm.print.border nor swarm.print.text seem to actualy get called...
By which I mean, they both SHOULD call swarm.update.geometry around which I placed set -x and set +x accordingly, yet, I dont see that part....
Code:
swarm.print.border() { # MODE
# Prints basic border for all lines, this should only be executed if COLUMNS > 25
# The calling function has to handle the NEWLINE required by 'printe' (-E)
swarm.protect "$FUNCNAME" "${@}" && exit 1
# Makes no sense to print visuals on such short lines
[[ ${COLUMNS} -lt 25 ]] && return 1
local MODE="" #name=""
case "${1/-}" in
e|p) MODE="basic" ;;
h) MODE="header" ;;
t) MODE="title" ;;
esac
# Make sure values are udpated
set -x
swarm.update.geometry
set +x
# Now prepare the seperate handling
case "$MODE" in
"basic")
PRINT_LEFT_IN="$c_reset"
PRINT_LEFT_OUT="${clrCL}${c_front}${c_back}"
PRINT_RIGHT_IN="${c_front}${c_back}"
pos_cor_num=0
;;
"header")
local filler_num=$(( $numEND - $(( ${#BORDER_RIGHT} * 2 )) + 2 ))
local filler_str=$($PRINTF "%*s" ${filler_num})
PRINT_LEFT_IN="$filler_str" #$c_reset"
PRINT_LEFT_OUT="${clrCL}${c_front}${c_back}"
PRINT_RIGHT_IN="" #${c_front}${c_back}"
pos_cor_num=0
;;
"title")
local filler_num=$(( $(( $COLUMNS / 2 * 2)) - $(( ${#BORDER_RIGHT} * 2 )) + 2 ))
local filler_str=$($PRINTF "%*s" ${filler_num})
PRINT_LEFT_IN="${c_invert}$filler_str" #$c_reset"
PRINT_LEFT_OUT="${clrCL}${c_front}${c_back}"
PRINT_RIGHT_IN="${c_reset}${c_front}${c_back}"
pos_cor_num=0
;;
esac
# Get some numbers
local identRight=$(( $lenRight + ${#clrCL} ))
local posLEFT="\33[$(( ${#BORDER_LEFT} - 2 ))G"
local posRIGHT="\33[$(( $numEND - $lenRight - $pos_cor_num ))G"
# Well, left aligned it works. isnt too hard
$PRINTF "\r${PRINT_LEFT_OUT}${posLEFT}${BORDER_LEFT}${PRINT_LEFT_IN}" >&2
# The right side is much more challenging
$PRINTF "${posRIGHT}${PRINT_RIGHT_IN}${BORDER_RIGHT}${PRINT_RIGHT_OUT}${c_reset}" >&2
$PRINTF "${posEND}"
}
swarm.update.geometry() { #
echo " ------------- " >&2
export COLUMNS="$($TPUT cols)"
export LINES="$($TPUT lines)"
# Set basic values
export BORDER_LEFT="${SWARM_THEME_DATA[border-left]}"
BORDER_RIGHT="${SWARM_THEME_DATA[border-right]}" # Do not export just yet
export clrFRONT="${SWARM_THEME_DATA[color-front]}"
export clrBACK="${SWARM_THEME_DATA[color-back]}"
# Check if border-right was set:
[ -z "$BORDER_RIGHT" ] && \
for((i=${#BORDER_LEFT}-1;i>=0;i--)); do BORDER_RIGHT="$BORDER_RIGHT${BORDER_LEFT:$i:1}"; done
export BORDER_RIGHT
# Get some numbers
export lenLeft="${#BORDER_LEFT}"
export lenRight="${#BORDER_RIGHT}"
export lenClrFont=${#clrFRONT}
export lenClrBack=${#clrBACK}
export identRight=$(( $lenRight + ${#clrCL} ))
# Pre-Calculate positions
export numHALF=$(( $COLUMNS / 2 ))
export numEND=$(( $numHALF * 2 ))
export posEND="\33[${numEND}G"
# swarm.print.border still needs extra handling for posLEFT
export posLEFT="\33[$(( $lenLeft + 2 ))G"
# Set colors
export c_front=$(swarm.color.fg ${SWARM_THEME_DATA[color-front]})
export c_back=$(swarm.color.bg ${SWARM_THEME_DATA[color-back]})
# If user wants extended logs, he shall have it
! $isRO && $doLogExt && init.log "$SWARM_MSG_INIT_PID_GEOMETRY: ${PPID:-$PID}"
}
export -f swarm.update.geometry
Code:
[~/prjs/SWARM] 0 $ time ./runtime
.........SWARM 0.4-17
| 2020-04-14 / 12:54:56\033[0m
\033[7mWelcome to a short introduction\033[0m
SWARM is not supposed to be called like this.
Instead it is to be sourced by your script to get access to it's functions.
\033[7m\033[0m
When calling SWARM like you just did, you should provide arguments.
They are:
./runtime config
./runtime help
./runtime tarball
one
[ ✓ ]
two
[ âœ- ]
real 0m0.079s
user 0m0.048s
sys 0m0.034s
[~/prjs/SWARM] 0 $
So, usualy, I would expect some ++ lines showing the working code, and the output of: echo " ------------- " >&2 from the update.geometry function itself...
But as you see, there is nothing.
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)
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)
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 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)
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)
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)
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)
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)