Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

tcl/tk escape oddities

Programming languages, Coding, Executables, Package Creation, and Scripting.
Message
Author
CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

tcl/tk escape oddities

#1 Post by CwF »

I am not tickled with this
using tcl tk, this doesn't work

Code: Select all

set uuid [exec id -u]
	grid [button .f1.nt.fi.baw -text "write array var sub escape test" -command {
foreach {var} {One Two Three} {fileutil::writeFile /run/user/$uuid/learn/$var.txt "$var\.txt and $var\000 array write test"}}]\
the result is an unreadable file.
Expected is a file with contents "Three.txt and Three000 array write test"

this is simplified from a 38x7 array using one variable $tower as three digits '605' to represent in most cases just 605, but in one case the desired line is "A 605000000 8VSB"
I did simply add an operation writing "A 605" then appending "000000 8VSB" and it works.
So this simplified example helped me narrow down to the $var\ part is the issue. Also same issue with $var.txt. In this case "605.txt" is the file created. In the complicated example $var.tower barfs while $var\.tower correctly creates 605.tower
$var = 605
$var\000 = unreadable
$var 000 = 605 000
$var\ 000 = 605 000
$var\ \b000 = 605 000 ;actually a code character that is here filtered out, it needs escaped!
($var)000 = (605)000
"$var"000 = errors extra characters after close-quote
No escape I've tried works.

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#2 Post by fabien »

I'm glad to see you're still at it and haven't given up 8)

What I understand from your problem is that you just need to protect your variable name. This is done like this: ${varname} (as in Bash for example).
This works:

Code: Select all

#!/usr/bin/env tclsh

package require fileutil

set uuid [exec id -u]

### I use /tmp/tcltest/ directory for this example
foreach {var} {One Two Three} {fileutil::writeFile /tmp/tcltest/$uuid/learn/$var.txt "$var\.txt and ${var}000 array write test"}

Code: Select all

$> cat /tmp/tcltest/1000/learn/Three.txt 
Three.txt and Three000 array write test
However, I don't understand why [your] result is an unreadable file. For me the file is readable:

Code: Select all

#!/usr/bin/env tclsh

package require fileutil

set uuid [exec id -u]

### I use /tmp/tcltest/ directory for this example
foreach {var} {One Two Three} {fileutil::writeFile /tmp/tcltest/$uuid/learn/$var.txt "$var\.txt and $var\000 array write test"}

Code: Select all

$> cat /tmp/tcltest/1000/learn/Three.txt 
Three.txt and Three array write test
Off Topic
I can't be sure I understand "I am not tickled with this": does it mean that you are not extremely interested in this problem, or that you are not happy with this problem, or does it mean something else? Thanks.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#3 Post by CwF »

Bingo! ${var} did work, I updated the write+append to just the one write, thank you!
I even found that elsewhere in my own example. I do get stuck at times thinking in a wrong 'format' and get some funny results when moving between bash and tcltk.

The backstory here is a gui front end for television tuners. I'm not impressed with heavy apps like Kodi. Instead of a dumbed down full screen 'App' I am more inclined to design a passive controller that does not run all the time and functions more like a launcher and back end tweaker. I'll figure out some screen shots in the future when things settle.

The main ingredient are Happauge quad tuners (pciid 14f1:8880) and this 'tv.tk' gui can manage 8. Primarily using gnutv for 'dvr' and 'file' output with mpv as the viewer and cron as the scheduler. MPV can also directly tune but there has always been some instability while gnutv is rock solid, except when certain dead air and timestamp errors hang the process. I do need to develop a 'canary' for a hung gnutv instance since with a single core at 100% among many I don't notice and the tell-tale is a failed future instance.

So we have a notebook tab with grid of icons to select the channel, radio buttons for the adapter choice, an 'Active' tab for current status and buttons to tap things, a 'Radio' tab destined for Visteon HD-Radio control now only input on/off and volume, the 'System' tab for odd things like this example where it writes out a large template of files for the 'Towers' tab which controls scanning the towers... a 'Network' tab may be added for streams but file based works better.

The 'Systems' tab does things like raising chickens and hatching eggs. Only /etc/channels.conf is persistent now. There is a fresh start issue I'd guess stumps some with this hardware. A scan would be the first step after installation. It FAILS. The bug is known, still not fixed, and even gnutv has a new issue in Bookworm, known. Magically, if we try on any pair (IOMMU 0,1 2,3 4,5 etc) at the same time with two different utilities the scan is successful and drops that critical first egg the tuneline. Now mpv or gnutv can hold one tuner open while the scans continue on its pair. So the Systems tab is the problem solver, documentation and scatters many files.

The Towers tab is tricky. The purpose here is to enable scanning per tower without a full monolithic sweep. One tower can be updated and inserted into the global /etc/channels.conf. Any change is seamless and if mobile scanning can happen in the background. This tv.tk is non-blocking so any other method of control still works. Those prior methods are bash scripts and are complicated enough in their parsing that I will likely not get them translated into tcltk, I just call them when needed. So '605' is a tower variable name and the list of files is 605, 605.cline, 605.dump, 605.number, 605.service, 605.tower, 605.tuneline. These are all written to /run/user and shared by all methods. Parsing the produced scan file into usability is messy, and there is a need for an editor to revise results and is implemented in the Tower tab. The station engineers are sloppy, so there are mislabeled fields and ambiguous data. Another gotcha is duplicate entries where there are two or more identical descriptions on multiple frequencies. The Tower tab helps me find these issues and correct them so all 'channels' are addressable. Most TV firmwares and computer Apps barf on these details, usually simply skipping the entry. If on two frequencies most logic picks the lower first and not the strongest.

Part of the issue is I built a very large antenna years ago and receive more than normal, hence the duplication. I currently can tune 93 channels, more than cablevision back when 'Video killed the Radio Star' was first aired - yes! I watched as the empty fuzz tuned into MTV's first broadcast...and haven't watch it since. This reminds me to mention my internet bandwidth is minimal and going to stay that way. Just like cable, the internet used to be a better place.

So anyway, I use a genmon and from it spawn tv.tk. It currently uses 16.5MiB and closes after use while anything active continues. I'm pleased. The control it provides is much better, faster, and easier. Still much to work on and on top of "I'm slow" the time slices I have to work with are few.

This concludes the TL;DR section. Thanks for push @Fabien. I will use this thread for more issues, and tag you every time. I am also developing herder.tk from a Thunar custom action. Contextually launched and tab selected by file type to do odd things like sparsify, layer, sendto and archive a qcow2, add a comment or tag or mpeg field, or trim or convert with ffmpeg, or add to a playlist. And memento.tk, the first inspired by your VersatileLauncher and modified to be the rare cli stuff I need to look up every time and further narrowed to xfce4-terminal with pkexec as needed.


"I am not tickled with this" is some form of humor that does (did) not translate well! I will try to embed "tickle" in every mention of tcltk! I am still very tickled with tcltk. When I get stumped, I frown and proclaim I'm not tickled!

I wear to many hats and language is not my strength, and I'm weak with context switches from thing to thing...

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#4 Post by fabien »

CwF wrote: 2023-04-17 17:30Thanks for push @Fabien. I will use this thread for more issues, and tag you every time.
You're very welcome. I'll try to help as much as I can.
CwF wrote: 2023-04-17 17:30I will try to embed "tickle" in every mention of tcltk!
Oh I see now :lol:

You seem to have some interesting projects to work on!

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#5 Post by CwF »

@fabien there's more!

I need to figure out screenshots! I have them...I killed all 'cloud' use.

Another similar snag, passing a variable to substitute within a exec command.

Code: Select all

foreach {var} {0 1 2 3 4 5 6 7} {row} {4 5 6 7 8 9 10 11} {
	grid [button .f1.nb.t4.lw$var -text watch -font {-size 6} -width 5 -command {exec /usr/bin/env mpv /dev/dvb/adapter${var}/dvr0 &}] -row $row -column 4 -sticky e}
It almost works "dev/dvb/adapter${var}/dvr0" becomes "dev/dvb/adapter1/dvr0" is all cases, so so coincidently works if I choose button .lw1 and if I hardcode "dev/dvb/adapter3/dvr0" and adapter 3 is active, mpv spawns and off we go...

In a similar way, a kill button failed to array in the same way and works in single lines for bk0-7 and it picks up the prior declared pid(0-7) variable.

Code: Select all

	grid [button .f1.nb.t4.bk7 -textvariable pid7 -font {-size 8} -width 5 -command {catch [exec kill -s TERM ${pid7}]; .f1.nb.t4.brR invoke}] -row 11  -column 0 -sticky w
converting the exec to calling a proc gave me the same result

Code: Select all

...command { watchIt $var }.....# var coming from the the foreach var
proc watchIt {var} {exec /usr/bin/env mpv /dev/dvb/adapter${var}/dvr0 &}
Since I evidently don't know how to properly use a variable nested in the output command I haven't tried an external script to take the variable. A bash script does work, but trying to avoid externals. I also nest as much as possible since one line per thought is already 700 lines. Scheduling cron, scanning towers, killing a tuned gnutv and most things are working in the condensed nested style. These issues are fixed by breaking up the one complex line into 8 lines and hard coding the variables per line, I just don't want to do that.

The above lines are from the 'Active' tab with 8 lines for each adapter and fields for pid, name(2.3 -dvr), watch button (code shown), signal strength, and an LED colored according to type (off gnutv-dvr or gnutv-file). I may need to add a column and add some logic since the mpv command is different (open dev/ versus mpg)

From the first tab, a grid of station id icons, selecting an icon and a adapter radio button works fine. Busy adapters are detected and greyed out.

Code: Select all

-text "tune gnutv" -command {exec /usr/bin/env gnutv -adapter $adapter -out dvr $channel &}
I'm so close!
Out of context it is hard for me to understand, so if it looks nuts to you - it is. Hopefully this fragment explains well enough?

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#6 Post by fabien »

CwF wrote: 2023-04-23 20:41Out of context it is hard for me to understand, so if it looks nuts to you - it is. Hopefully this fragment explains well enough?
I have to admit I had a little trouble being sure about your problem. I even took the wrong path until I implemented the whole shebang. If you could provide working examples it would be much easier to figure out and would help a lot.
For instance, the following does not meet your expectations:

Code: Select all

#!/usr/bin/env wish

foreach {var} {0 1 2 3 4 5 6 7} {row} {4 5 6 7 8 9 10 11} {
   button .lw$var -text watch$var -font {-size 6} -width 5 -command {puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]}
   grid .lw$var -row $row -column 0 -sticky e
}
#set var 99
Uncommenting the last line should help to understand what is going on.
Curly brackets in Tcl act like single quotes in Bash, i.e. variable expansions do not occur. Note that this may be desired behavior.

This should help solve your problems:

Code: Select all

#!/usr/bin/env wish

foreach {var} {0 1 2 3 4 5 6 7} {row} {4 5 6 7 8 9 10 11} {
   button .lw$var -text watch$var -font {-size 6} -width 5 -command "puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]"
   grid .lw$var -row $row -column 0 -sticky e
}
Let us know if any issues remain.

User avatar
ticojohn
Posts: 1284
Joined: 2009-08-29 18:10
Location: Costa Rica
Has thanked: 21 times
Been thanked: 44 times

Re: tcl/tk escape oddities

#7 Post by ticojohn »

Not trying intrude, but I was amazed to see that others are using tcl/tk. I'm not that much of a coder, so I can't help with the problem. Just wanted to say hey. I use Visual Tcl for all the tcl/tk programs I muck together. :roll:
I am not irrational, I'm just quantum probabilistic.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#8 Post by CwF »

ticojohn wrote: 2023-04-24 23:29 I was amazed to see that others are using tcl/tk.
More the Merrier!
It's starting to click.tcl tk seems a perfect "Glue".
fabien wrote: 2023-04-24 20:23 If you could provide working examples it would be much easier to figure out and would help a lot.
I will clean up and post whole sections trying to include...Well I maybe should just post all the sections. We'll see how many are interested. I do have the functions above working, just not a working long liner. More coming.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#9 Post by CwF »

Here we go with tv.tk!

Files will be scattered in /run/user/uuid/tower, ignore.
without a /home/user/tv_scedule.cron present the Schedule tab is not displayed
notes and random nonsense included
###??? are questions
Overall it is working for me, I will test on an clean computer at some point to test how it does when all support bash scripts and previous configurations are not present, some of those noted in the 'Systems' tab area.

...and yes, all those icons are fat! In my editor (Mousepad) they are not word wrapped, they are one long line!

app.php/pastebin/?mode=view&s=28

Update; here are the helper scripts in sloppy raw form still evolving

Code: Select all

#!/bin/bash
#/usr/local/bin/tv_status.sh
uuid=$(id -u $(whoami))
tfs="/run/user/$uuid/tower"
A0=$(ps S -C "gnutv" | awk '/adapter 0/{print}')
A1=$(ps S -C "gnutv" | awk '/adapter 1/{print}')
A2=$(ps S -C "gnutv" | awk '/adapter 2/{print}')
A3=$(ps S -C "gnutv" | awk '/adapter 3/{print}')
# poll active signal strength, inactive show "|"
SNR0=$(femon -a0 -H -c1 | awk -F" " '/signal/{print $5}')
SNR1=$(femon -a1 -H -c1 | awk -F" " '/signal/{print $5}')
SNR2=$(femon -a2 -H -c1 | awk -F" " '/signal/{print $5}')
SNR3=$(femon -a3 -H -c1 | awk -F" " '/signal/{print $5}')
SNR4="|"
SNR5="|"
SNR6="|"
SNR7="|"
# discrete channel, also use to know 'on' for adapter led's
C0=$(echo $A0 | awk  -F" " '{print $NF}')
C1=$(echo $A1 | awk  -F" " '{print $NF}')
C2=$(echo $A2 | awk  -F" " '{print $NF}')
C3=$(echo $A3 | awk  -F" " '{print $NF}')
#C4=$(ps S -C "gnutv" | awk  -F" " '/adapter 4/{print $NF}')
#C5=$(ps S -C "gnutv" | awk  -F" " '/adapter 5/{print $NF}')
#C6=$(ps S -C "gnutv" | awk  -F" " '/adapter 6/{print $NF}')
#C7=$(ps S -C "gnutv" | awk  -F" " '/adapter 7/{print $NF}')
# find gnutv stream on dvr , if C variable in use remove fields for $C=$10
D0=$(echo $A0 | awk -F" " '/dvr/{print $9}')
D1=$(echo $A1 | awk -F" " '/dvr/{print $9}')
D2=$(echo $A2 | awk -F" " '/dvr/{print $9}')
D3=$(echo $A3 | awk -F" " '/dvr/{print $9}')
#D4=$(ps S -C "gnutv" | awk '/adapter 4/' | awk -F" " '/dvr/{print $9" "$10}')
#D5=$(ps S -C "gnutv" | awk '/adapter 5/' | awk -F" " '/dvr/{print $9" "$10}')
#D6=$(ps S -C "gnutv" | awk '/adapter 6/' | awk -F" " '/dvr/{print $9" "$10}')
#D7=$(ps S -C "gnutv" | awk '/adapter 7/' | awk -F" " '/dvr/{print $9" "$10}')
# find gnutv writing out to file , Path and then File, may include $11 "file"
P0=$(echo $A0 | awk -F" " '/file/{print $12}') 
P1=$(echo $A1 | awk -F" " '/file/{print $12}')
P2=$(echo $A2 | awk -F" " '/file/{print $12}')
P3=$(echo $A3 | awk -F" " '/file/{print $12}')
F0=$(echo $P0 | awk -F"/" '{print $NF}')
F1=$(echo $P1 | awk -F"/" '{print $NF}')
F2=$(echo $P2 | awk -F"/" '{print $NF}')
F3=$(echo $P3 | awk -F"/" '{print $NF}')
#F4=$(ps S -C "gnutv" | awk '/adapter 4/' | awk -F" " '/file/{print $11" "$12" "$13}')
#F5=$(ps S -C "gnutv" | awk '/adapter 5/' | awk -F" " '/file/{print $11" "$12" "$13}')
#F6=$(ps S -C "gnutv" | awk '/adapter 6/' | awk -F" " '/file/{print $11" "$12" "$13}')
#F7=$(ps S -C "gnutv" | awk '/adapter 7/' | awk -F" " '/file/{print $11" "$12" "$13}')
# find active mpv viewer, mpv $channel@$adapter will be different
V0=$(ps S -C mpv | awk /adapter0/ | awk -F" " '/mpv/{print $5}')
V1=$(ps S -C mpv | awk /adapter1/ | awk -F" " '/mpv/{print $5}')
V2=$(ps S -C mpv | awk /adapter2/ | awk -F" " '/mpv/{print $5}')
V3=$(ps S -C mpv | awk /adapter3/ | awk -F" " '/mpv/{print $5}')
#V4=$(ps S -C mpv | grep adapter0 | cut -d ":" -f 2 | cut -d ' ' -f 2)
#V5=$(ps S -C mpv | adapter1 | cut -d ":" -f 2 | cut -d ' ' -f 2)
#V6=$(ps S -C mpv | adapter2 | cut -d ":" -f 2 | cut -d ' ' -f 2)
#V7=$(ps S -C mpv | adapter3 | cut -d ":" -f 2 | cut -d ' ' -f 2)
# PIDof Process
I0=$(echo $A0 | awk  -F" " '{print $1}')
I1=$(echo $A1 | awk  -F" " '{print $1}')
I2=$(echo $A2 | awk  -F" " '{print $1}')
I3=$(echo $A3 | awk  -F" " '{print $1}')
#I4=$(ps S -C "gnutv" | awk  -F" " '/adapter 4/{print $NF}')
#I5=$(ps S -C "gnutv" | awk  -F" " '/adapter 5/{print $NF}')
#I6=$(ps S -C "gnutv" | awk  -F" " '/adapter 6/{print $NF}')
#I7=$(ps S -C "gnutv" | awk  -F" " '/adapter 7/{print $NF}')
# literal line
echo "$SNR1 $C1 $F1$D1 $V1
$SNR2 $C2 $F2$D2 $V2
$SNR3 $C3 $F3$D3 $V3
$SNR4 $C4 $F4$D4 $V4
$SNR5 $F5$D5 $C5 $V5
$SNR6 $F6$D6 $C6 $V6
$SNR7 $F7$D7 $C7 $V7
$SNR0 $F0$D0 $V0">/run/user/$uuid/tower/status.txt
# channel and name/device
echo "$C1 $F1$D1 $V1">$tfs/act1
echo "$C2 $F2$D2 $V2">$tfs/act2
echo "$C3 $F3$D3 $V3">$tfs/act3
#echo "$C4 $F4$D4 $V4">$tfs/act4
echo "not installed">$tfs/act4
#echo "$F5$D5 $C5 $V5">$tfs/act5
echo "not installed">$tfs/act5
#echo "$F6$D6 $C6 $V6">$tfs/act6
echo "not installed">$tfs/act6
#echo "$F7$D7 $C7 $V7">$tfs/act7
echo "not installed">$tfs/act7
echo "$C0 $F0$D0 $V0">$tfs/act0
echo "$SNR0">$tfs/ss0
echo "$SNR1">$tfs/ss1
echo "$SNR2">$tfs/ss2
echo "$SNR3">$tfs/ss3
echo "$SNR4">$tfs/ss4
echo "$SNR5">$tfs/ss5
echo "$SNR6">$tfs/ss6
echo "$SNR7">$tfs/ss7
echo "$I0">$tfs/pid0
echo "$I1">$tfs/pid1
echo "$I2">$tfs/pid2
echo "$I3">$tfs/pid3
echo "$I4">$tfs/pid4
echo "$I5">$tfs/pid5
echo "$I6">$tfs/pid6
echo "$I7">$tfs/pid7
echo "$P0">$tfs/p0
echo "$P1">$tfs/p1
echo "$P2">$tfs/p2
echo "$P3">$tfs/p3
echo "$P4">$tfs/p4
echo "$P5">$tfs/p5
echo "$P6">$tfs/p6
echo "$P7">$tfs/p7
exit 0

Code: Select all

#!/bin/bash
#/usr/local/bin/scan_tower.sh
#tv.tk helper and thunar CA by file *.tower
# mkdir /run/user/$uuid/tower/ created in ~/.profile
base=${@%.*}
uuid=$(id -u)
wdir="/run/user/$uuid/tower/"
#echo $base
#echo $uuid
#echo $wdir
script -c "scan "$wdir$base".tower" "$wdir$base".dump
grep number "$wdir$base".dump | cut -d '.' -f 2 | cut -d ':' -f 2,3 | sed s/:/./ | tr -d [:blank:] > "$wdir$base".number
grep number: "$wdir$base".dump | cut -d ':' -f 2,3,4 > "$wdir$base".service
grep "(tuning failed)" "$wdir$base".dump >> "$wdir$base".service
grep 8VSB: "$wdir$base".dump |  cut -d ':' -f 2-6 > "$wdir$base".tuneline
paste -d :'\n' "$wdir$base".number "$wdir$base".tuneline > "$wdir$base".cline
paste -d '\n' "$wdir$base".service "$wdir$base".cline > "$wdir$base"
#mousepad  "$wdir$base"
exit 0

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#10 Post by fabien »

I managed to get it to work, but of course haven't really tested it without a tuner card. Nothing against some screenshots I guess? :wink:
# this array same as kill array, not passing variable to 'within' exec $var
You didn't try my solution?
###??? fileutil test exist does not work, creates new each time - never doesn't
# I must have something wrong in that line
While Tcl accepts short forms of commands, fileutil::test seems not to. And fileutil::test does not work with the syntax if {[fileutil::test myFile exist] == true}

Code: Select all

#!/usr/bin/env tclsh

set fd [open /tmp/tcltestfile w]
puts $fd "test"
close $fd
set file1 /tmp/tcltestfile; set file2 /tmp/filedoesntexist
if {[file exist $file1] == 1} {puts "A:$file1 exists"} else {puts "A:$file1 doesn't exist"}
if {[file exists $file1] == 1} {puts "A:$file1 exists"} else {puts "A:$file1 doesn't exist"}
if {[file exists $file1]} {puts "A:$file1 exists"} else {puts "A:$file1 doesn't exist"}
if {[file exists $file2]} {puts "A:$file2 exists"} else {puts "A:$file2 doesn't exist"}
package require fileutil
if {[fileutil::test $file1 exist]} {puts "B:$file1 exists"} else {puts "B:$file1 doesn't exist"}
if {[fileutil::test $file1 exists]} {puts "B:$file1 exists"} else {puts "B:$file1 doesn't exist"}
file delete /tmp/tcltestfile
if {[fileutil::test $file1 exists]} {puts "B:$file1 exists"} else {puts "B:$file1 doesn't exist"}
Output:

Code: Select all

A:/tmp/tcltestfile exists
A:/tmp/tcltestfile exists
A:/tmp/tcltestfile exists
A:/tmp/filedoesntexist doesn't exist
B:/tmp/tcltestfile doesn't exist
B:/tmp/tcltestfile exists
B:/tmp/tcltestfile doesn't exist
###??? is 'fileutil::writeFile' the only way to create a file? no simple 'file create <path>' "content"?
fileutil::writeFile simplifies the traditional procedure (see my script above for the normal way).
Attachments
Free-to-Air01.png
Free-to-Air02.png
Free-to-Air03.png

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#11 Post by CwF »

I bow in gracious gratitude, Thank You @fabien

Actually I haven't looked to revise it since the post asking about the arrays. I have come across this https://wiki.tcl-lang.org/page/Is+white ... ant+in+Tcl
That helped with my misconceptions too.

I suppose I should post the helper bash scripts for anyone that would like to try it with tuner hardware.

I will update the post with the pastebin with changes soon. Along with the suggestions and more functionality it will update every few weeks. I did run it the other day on a virgin machine to see the improperly handled conditions and added a few more 'exist' checks and have many more thoughts to implement. In parallel some other tickle projects are forming up, I will post those eventually.
This time of year I turn into the gardener. Like computers, that never ends until it's to late, next!

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#12 Post by CwF »

Oh, also I've noticed resolution concerns. The screenshots appear as designed, so I assume global DPI is 96-120. I put it together on a 1080@120 screen, on the virgin setup I had it at 144 and the station icons are smaller, and odd looking. I'm not sure what to do about that yet. As I test on more setups I'll have more results with one at 192. I may just have to redo the icons...

I expect to be able to drop the .f2 field since I likely won't use it.

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#13 Post by fabien »

CwF wrote: 2023-05-05 16:28I have come across this https://wiki.tcl-lang.org/page/Is+white ... ant+in+Tcl
Thank you very much, it's a must read. So my solution wasn't perfect and could lead to unexpected problems. In my defense, I don't think I've ever done what you did and called a function instead, but more generally it's good to be aware of these kinds of things.

Code: Select all

#!/usr/bin/env wish

foreach {var} {0 "1 X" 2 3 4 5 6 7} {col} {4 5 6 7 8 9 10 11} {
   #button .lw$var -text watch$var -command {puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]}         ;# "9 9", OK
   #button .lw$var -text watch$var -command "puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]"         ;# "1 X" triggers an error
   #button .lw$var -text watch$var -command [concat puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]]  ;# "1 X" triggers an error
   button .lw$var -text watch$var -command [list puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]]     ;# OK
   ### see https://www.tcl.tk/man/tcl/TclCmd/list.html
   ### “List produces slightly different results than concat: concat removes one level of grouping before forming the list”

   if {$col < 6} {
      puts {puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]}
      puts "puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]"
      puts [concat puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]]
      puts [list puts [exec /usr/bin/env /bin/echo "/dev/dvb/adapter$var/dvr0"]]
      puts "button command: [.lw$var cget -command]\n"
   }

   grid .lw$var -column $col -row 0
}
set var "9 9"
But if you look at the output of this script, you probably fall in one of the "gotcha" of the link you provided (Q. I'm trying to build up a command for later execution but am having trouble getting some variables to evaluate now, and some to evaluate later when the command is run). You want 'adapter$var' to be evaluated but not the entire command '{exec /usr/bin/env mpv /dev/dvb/adapter$var/dvr0 &}', so you have to rely on a function (called procedure in Tcl). I plan to share a tickle ^^ script (from 2016) soon and you'll see that it's best to separate the functions from the GUI part (widgets and grid, which are themself separated).

Also, the construct if {[fileutil::test myFile exists] == true} actually works correctly (but is unnecessary). On second thought, I was surprised that it didn't and so I redid the test (I must have been confused by the exist/exists thing).

Code: Select all

$> tclsh
% package require fileutil
% if {[fileutil::test /etc/fstab exists] == 1} {puts "file exists"} else {puts "file does not exist"}
file exists
% if {[fileutil::test /etc/fstab exists]} {puts "file exists"} else {puts "file does not exist"}
file exists
% if {[fileutil::test /etc/fstab exist]} {puts "file exists"} else {puts "file does not exist"}
file does not exist
% puts [fileutil::test /etc/fstab exists]
1   ;# boolean true, Tcl return code is 0 (OK, true)
% puts [fileutil::test /etc/fstab exist]
0   ;# boolean false, Tcl return code is 1 (error, false)
% proc f_true {{args ""}} {return -code 0 1}
% puts [f_true isn't it?]
1
% if {[f_true isn't it?] == 1 } {puts "it is"} else {puts "uh"}
it is
% if {[f_true isn't it?]} {puts "it is"} else {puts "uh"}
it is
CwF wrote: 2023-05-05 16:28I suppose I should post the helper bash scripts for anyone that would like to try it with tuner hardware.
Anyone who comes here in desperate need of a GUI front end for television tuners probably deserves it.
CwF wrote: 2023-05-05 16:42 Oh, also I've noticed resolution concerns. The screenshots appear as designed, so I assume global DPI is 96-120. I put it together on a 1080@120 screen, on the virgin setup I had it at 144 and the station icons are smaller, and odd looking. I'm not sure what to do about that yet. As I test on more setups I'll have more results with one at 192. I may just have to redo the icons...
Sorry, I've no clue about this. If you can't figure out what the problem is, you can post a screenshot and maybe someone will have an idea. I would be interested because this is something I don't know.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#14 Post by CwF »

fabien wrote: 2023-05-07 23:39 Anyone who comes here in desperate need of a GUI front end for television tuners probably deserves it.
It would be nice if someone liked it and used it. There really isn't a good front end in my opinion that functions in this simplistic way. I'd guess many people like the all consuming monolithic programs like kodi or the like. This widget gets out of the way and at first was motivated by the difficult scan step. I've never seen or used a better way to scan (including actual tv firmwares) and I've had a tv tuner in many computers since long before things were digital. Anyway, I added the scripts to the post above, I think that covers it.

On that note, I have included some notes in the tv.tk file itself noting these external required scripts. I would like to have a way to embed them into the script, not in an executable way but packaged in a way the tcl script could create the bash script files. So as reference to keep everything in one file. Even if placement and marking as executable needs manually done by the user. Using tcltk to write to an executable to root/staff space might be a difficult?
fabien wrote: 2023-05-07 23:39 Also, the construct if {[fileutil::test myFile exists] == true} actually works correctly (but is unnecessary).
I don't have the flow in my brain right now, but it is necessary and working. Testing on a fresh boot if the temporary files are not populated then tv.tk won't start, and/or if it is populated we would not want to overwrite the files = somewhere I ran into wrong info out of sync. Both the cron and scan information is prone to user error via incomplete info in the temp files, ie empty field when building the tv_shedule.cron or channels_by_numbers.conf. Oh, a pipe "|" response in "$tfs/ss#" will turn off the active led! So you have things commented out in order to run it!
fabien wrote: 2023-05-07 23:39 I would be interested because this is something I don't know.
Concerning the resolution I vaguely remember a mention in the Sid forums about tcltk looking strange and a change from earlier releases. Not sure if that was in the same category or not. The Stations tab should occupy all the available space as in your screenshots. Using a higher DPI all is normal except the icon grid in 'Stations' is fractionally smaller not filling the space. Maybe I'm confused with the trend to 'scale' the desktop with DE tools but it's nonsense to me and I've been using DPI to scale the desktop ever since I had dual SGI 16:10 tube monitors. Based of off 96 as 1X, a modern 2X scale factor for me is just a DPI of 192. Works for me...
fabien wrote: 2023-05-07 23:39 soon and you'll see that it's best to separate the functions from the GUI part (widgets and grid, which are themself separated).
I *think* I've noticed this. The buttons that do things that take a few seconds to complete remain depressed until completed. While thinking the GUI is unresponsive. I ignore it. It's almost like there is a missing '&' to instruct the completion in the background while releasing the gui. This is why I don't ask tv.tk to figure out 'tv_status.sh" on launch because unless an adapter is tuned it waits for a timeout, times 8. The kill function does this, yet I can simply click intentionally on the unresponsive gui and it completes multiple kills correctly. I may divorce some of the combined statements, maybe not.

I did find a reference that stated "There are as many tickle styles as there are ticklers" so maybe a paraphrase but I took it as license to develop whatever style makes sense to my brain. I like 'jit' ordering (just in time), that is the line immediately before it's actually needed. I like tight, nested, excessively long lines. I can't stand the 'white space lovers' style with dangling {
.......... }
.....}
}
consuming line after line in a 'style' that makes no sense to me. It does NOT help readability or comprehension in my case. I have been breaking up the lines of most things to fit within a standard wordwrap and if I am in a 'style' it's still developing.

As I mentioned I took the time to make a Thunar custom action to format those icons into a long line for paste into the tcltk script, so dozens of them consume a single page down instead of dozens of key presses.

Code: Select all

echo "set  $(basename %n .png)B64 {\n"$(base64 %f)"\n}\nimage create photo $(basename %n .png)Icon -data $"$(basename %n .png)"B64; unset $(basename %n .png)B64" | xclip -sel clip
Lately my time slices for this is divided with herder.tk that seems to be merging with memento.tk Lots of challenges there and some a waste of time - but I'd like to condense a handful of Thunar custom actions into one to simplify my right click context menu. I'll post when minimally useful!

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#15 Post by fabien »

CwF wrote: 2023-05-08 17:45On that note, I have included some notes in the tv.tk file itself noting these external required scripts. I would like to have a way to embed them into the script, not in an executable way but packaged in a way the tcl script could create the bash script files. So as reference to keep everything in one file.
Like this for instance

Code: Select all

#!/usr/bin/env tclsh

set myBashScript {#!/usr/bin/env bash
echo "Hello TKitty" >/tmp/myBashScript.output}

exec /usr/bin/env bash -c "$myBashScript"
or like this

Code: Select all

#!/usr/bin/env tclsh

set myBashFile /tmp/myBashScript
set fd [open $myBashFile w]
puts $fd "#!/usr/bin/env bash
echo \"Hello TKitty\" >${myBashFile}.output"
close $fd
exec /usr/bin/env bash -c "source $myBashFile"
CwF wrote: 2023-05-08 17:45
fabien wrote: 2023-05-07 23:39 Also, the construct if {[fileutil::test myFile exists] == true} actually works correctly (but is unnecessary).
I don't have the flow in my brain right now, but it is necessary and working.
Of course! I don't say that your test is unnecessary, just that the construct {[fileutil::test myFile exists] == true} can be simplified with {[fileutil::test myFile exists]}

Code: Select all

if {[fileutil::test myFile exists] == 1} {some action}
if {[fileutil::test myFile exists]} {some action}
CwF wrote: 2023-05-08 17:45The Stations tab should occupy all the available space as in your screenshots. Using a higher DPI all is normal except the icon grid in 'Stations' is fractionally smaller not filling the space.
Is it what we can see in my first screenshot?
In my second screenshot, I forced the font size of notebook tabs

Code: Select all

ttk::style configure TNotebook.Tab -font {default 8}
You will have to change the other elements fonts that take too much space at 192DPI.
Edit: Making a new icon set twice as big for 192 DPI (as you thought) would probably be a better solution than reducing the font sizes as it would keep the interface proportion I suppose.
CwF wrote: 2023-05-08 17:45I did find a reference that stated "There are as many tickle styles as there are ticklers" so maybe a paraphrase but I took it as license to develop whatever style makes sense to my brain.
That's right, you're free as in free speech and in freestyle, it's your code.
Attachments
Free-to-Air_192DPI01.png
Free-to-Air_192DPI02.png

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#16 Post by CwF »

fabien wrote: 2023-05-09 20:42
CwF wrote: 2023-05-08 17:45On that note, I have included some notes in the tv.tk file itself noting these external required scripts. I would like to have a way to embed them into the script, not in an executable way but packaged in a way the tcl script could create the bash script files. So as reference to keep everything in one file.
Like this for instance

Code: Select all

#!/usr/bin/env tclsh

set myBashScript {#!/usr/bin/env bash
echo "Hello TKitty" >/tmp/myBashScript.output}

exec /usr/bin/env bash -c "$myBashScript"
or like this

Code: Select all

#!/usr/bin/env tclsh

set myBashFile /tmp/myBashScript
set fd [open $myBashFile w]
puts $fd "#!/usr/bin/env bash
echo \"Hello TKitty\" >${myBashFile}.output"
close $fd
exec /usr/bin/env bash -c "source $myBashFile"
Almost, I'm making headway!!!
Except the file needs to be a random anything goes script, then most importantly marked executable!

So my intermediate cheat for bash scripts to complicated for me to translate into pure tcl I have my "CwF official" pattern!

Code: Select all

# to encapsulate a bash script within; write out, mark execurtable and execute:
package require fileutil
set tfs "/run/user/$uuid/.tk or .tcl scriptname/"
proc bashshell {} { set eF {#!/bin/bash
maybe straight, maybe slightly modified, but pretty much the bash as is, no substitutions,}
;fileutil::writeFile ${::tfs}exec.sh $eF; file attributes ${::tfs}exec.sh -permissions rwxrwxrwx; catch {exec ${::tfs}exec.sh options; }
So far I have some crazy long scripts taken prisoner and working. One script in herder.tk returns a report of 'reset' capable iommu groups. It works and even with a catch still errors with a mysterious can't find "". It works, so ?.

As I work to include scan and other functions into tv.tk eliminating the external bash.sh requirements I'm getting ticklish!
After more polish I will put up herder.tk and the cleaned up tv.tk, still working...

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: tcl/tk escape oddities

#17 Post by fabien »

Great to hear from you!
CwF wrote: 2023-06-04 18:46 Except the file needs to be a random anything goes script, then most importantly marked executable!
Not a big deal, but any reason why you can't just source it?
From man 1 bash
source filename [arguments]
Read and execute commands from filename in the current shell environment [...]
The file searched for in PATH need not be executable.
CwF wrote: 2023-06-04 18:46

Code: Select all

rwxrwxrwx
Bad! Bad! Bad! :lol: (I know, /run/user/$uuid/ is chmod 700)
CwF wrote: 2023-06-04 18:46One script in herder.tk returns a report of 'reset' capable iommu groups. It works and even with a catch still errors with a mysterious can't find "". It works, so ?.
Does it generate a Tk error box or does it output in the terminal? In the terminal I guess? Sounds like the system is warning of something, but it works since it's just a reset of something (VM related, I suppose?) Is it a Bash script within Tcl or is it pure Tcl?
CwF wrote: 2023-06-04 18:46As I work to include scan and other functions into tv.tk eliminating the external bash.sh requirements I'm getting ticklish!
8)
CwF wrote: 2023-06-04 18:46After more polish I will put up herder.tk and the cleaned up tv.tk, still working...
8) 8)

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#18 Post by CwF »

fabien wrote: 2023-06-04 22:32 Not a big deal, but any reason why you can't just source it?
No good reason at all!
I simply ask myself, can I pack it all into one file?
maybe...
Can everything be tcltk?
I don't know!
So, I call it the intermediate cheat!
fabien wrote: 2023-06-04 22:32 Bad! Bad! Bad! :lol: (I know, /run/user/$uuid/ is chmod 700)
Yes, I know. However, in herder.tk {exec exec.sh} is recycled for ALL scripts, dozens. It is dynamically written out for each function. So the file exist for microseconds if desired. I decided to leave it until overwritten by the next button push.

exec.sh when written out as an actual file does need permissions set, I tried without. "Permission Denied". In herder.tk, some are also as root.

Code: Select all

#set iommuresetreport [puts {!/bin/bash for iommu_group in $(find /sys/kernel/iommu_groups/ -maxdepth 1 -mindepth 1 -type d);do echo "IOMMU group $(basename "$iommu_group")"; for device in $(\ls -1 "$iommu_group"/devices/); do if [[ -e "$iommu_group"/devices/"$device"/reset ]]; then echo -n "[RESET]"; fi; echo -n $'\t';lspci -nns "$device"; done; done > ${tfs}response}]
proc iommuresetreport {} { set eF {#!/bin/bash
for iommu_group in $(find /sys/kernel/iommu_groups/ -maxdepth 1 -mindepth 1 -type d);do echo "IOMMU group $(basename "$iommu_group")"; for device in $(\ls -1 "$iommu_group"/devices/); do if [[ -e "$iommu_group"/devices/"$device"/reset ]]; then echo -n "[RESET]"; fi; echo -n $'\t';lspci -nns "$device"; done; done}
;[fileutil::writeFile ${::tfs}exec.sh $eF; file attributes ${::tfs}exec.sh -permissions rwxrwxrwx; catch {exec ${::tfs}exec.sh > ${::tfs}response}; moO]}
###???
Lifted directly from the working script. It gives a dialog box error AFTER posting results in the test field by moO.

Code: Select all

invalid command name ""
invalid command name ""
    while executing
The old script works perfectly

Code: Select all

.... it's very long...
IOMMU group 3
[RESET]	00:02.0 PCI bridge [0604]: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2a [8086:3c04] (rev 07)
IOMMU group 21
	04:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GL [Quadro K600] [10de:0ffa] (rev a1)
	04:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1)
IOMMU group 2
[RESET]	00:01.1 PCI bridge [0604]: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1b [8086:3c03] (rev 07)
IOMMU group 20
	03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] [10de:1380] (rev a2)
	03:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:0fbc] (rev a1)
IOMMU group 10
[RESET]	00:1b.0 Audio device [0403]: Intel Corporation C600/X79 series chipset High Definition Audio Controller [8086:1d20] (rev 06)
......and on and on and on....
Anyway, herder.tk is an amalgam of these rarely used never remembered elements all packed into one widget thing. I've decided to make it very conditional in how it starts up. So not everything is shown and it depends on what click fires it off.

It is a thunar custom action for most files and directories

Code: Select all

wish /usr/local/bin/herder.tk $(echo %f)
So it's always a right click away from action. Instead of the inspired memento.tk launcher idea I decided to integrate it into herder. ONE widget that functions for all custom actions otherwise cluttering thunar's right click menu. And also terminal cli eliminator! Actually it can spawn a terminal, in a tab, or a root terminal, and... we'll see.

So far it depends on AtomicParsley, mediainfo, dpkg, dmidecode, qemu-utils(thin), liobguestfs-toools(fat), libimage-exiftool-perl, python3-mutegen, mpv with configured file type profiles, XFCE with sudo and pkexec rights, and maybe more.

If it needs to be done and can be done, it's going into herder.tk.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#19 Post by CwF »

I've come up with a very bizarre problem. One that makes me hesitant to post herder.tk for others.

First, the operation uses a temp file that resides in memory and is recycled for all kinds of purposes. That's not an issue, but leads to one.

Second, herder.tk opens anything, or nothing, and does stuff depending. One of those things is to open a video file, have it tell you all about it, open it to watch, open it to edit, and modify the tags (atoms) if you'd like. No problems.

I have found that depending on the file name of the video, herder.tk may read the binary contents into the temp file, as in the whole file, for some unknown reason. That is not the instructed behavior and there isn't even an option to do so. It should read only the results of commands that are short, even when tagging it reads from the temp file and not to it...

Bad filenames are "12O'ClockHigh_121_The Clash.dv", "1short.dv" and other variations. Rename to short.dv, no issue on the same file. Rename a random file to "1short.dv" or any 'video' extension and it reads the entire content into the temp file, and displays the code like it's morphed into a hex editor.

So my machine survives. It just takes some time to display, alerting me to the issue. It usually opens instantly. I said my machine survives, but the scenario is clear. If someone happens to open a video file named 1short, or clash, or whatever combo yet undetermined, then they need to have that memory free, or maybe crash. What if that video file is many GB's? To answer any wondering, yes, it will open a 10GB file like a hex editor and display it, yes the temp file is the whole 10GB written out, yes it continues without issue and doesn't crash.... IF you have gobs of memory.

Some of the parsing section;

Code: Select all

if {[file isdirectory $basefile] == 1} {.f1.nb select .f1.nb.dir; ls1} else {}
# text as input
foreach {var} {.txt .conf .html .sh .tcl .tk .genmon .qstat } {if {[regexp -- $var [file tail $basefile]] == 1} {.f1.nb select .f1.nb.text; popWord; .f1.nb.text.bcat invoke} else {}}
# text as input requiring root (or user is 'staff') ? chain onto regular text to just add pkexec mouepad buttoon?
foreach {var} {.conf .sh .tcl .tk .genmon .qstat } {if {[regexp -- $var [file tail $basefile]] == 1} { popCode; } else {}}
# pic as input
foreach {var} {.jpg .jpeg .png } {if {[regexp -- $var [file tail $basefile]] == 1} {.f1.nb select .f1.nb.media; popImage; .f1.nb.media.bminfo invoke
; if {[regexp -- png [file tail $basefile]] == 1} {popIrow2}  else {}} else {}}
# audio as input
foreach {var} {.mp3 .m4a .aac .ac3 .wav .wma} {if {[regexp -- $var [file tail $basefile]] == 1} {.f1.nb select .f1.nb.media; popAudio; } else {}}
# video as input
foreach {var} {.dv .mpg .mpeg .mkv .m4v .avi} {if {[regexp -- $var [file tail $basefile]] == 1} {.f1.nb select .f1.nb.media; popVideo; } else {}}
# qcow2 as input, already above

# /dev/disk/ as input
if {[regexp -- disk [file dirname $basefile]] == 1} {.f1.nb select .f1.nb.cow} else {}
Modifying the {.dv .mpg etc} part doesn't change the error, eliminating popVideo that populates video specific functions doesn't help either. Non-video filetypes which are mostly doing the same thing are not affected.

It seems restricted to video files with some "sh" combo in the name. I'm baffled.

So, I think, test, wonder, think..watch bees in the garden...

In that parsing code if it finds a *.sh it sets up the text handling part of herder.tk. It also invokes a 'cat' of the file and displays it...hmmm. Yes, that's it. Why? it picks up the 'sh' in only odd combos and interprets it as ".sh" and I included the dot that tcl/tk apparently ignores! I leave out the first .sh reference, and leave the second, the the issue disappears since it no longer cats a massive file.

So, fixable but I'd like it to do correctly for a *.sh file and cat the contents for instant display without an extra click...

Takeaway? My non-malicious friendly well intention code could blow up your computer!

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: tcl/tk escape oddities

#20 Post by CwF »

Clarified.
It's any and all names used to open herder.tk containing any string (ignoring the dot) in any of the if statements. It just took a large video file for me to notice.

So the parsing statements as used are not safe to mix in the way I have done.

...but it does work @fabien!

Post Reply