You are not logged in.

#1 2019-01-06 05:16:53

garrym
Member
Registered: 2019-01-06
Posts: 9

obfuscated dialog display with checkbox

Hello,

I am trying to load a local file with ISO alpha-2 codes & names of countries in dialog with checkbox but I see obfuscated output on the dialog screen https://pasteboard.co/HV8Nv8S.png.

I am using dialog with these options -

dialog --cr-wrap --single-quoted --trim --checklist "Choose Country ISO Codes:" 100 160 80 `cat /tmp/iso.txt` off

My input file contains text like this here -

AW   Aruba
AF   Afghanistan
AO   Angola
AI   Anguilla
AX   Åland Islands
AL   Albania
AD   Andorra
AE   United Arab Emirates
AR   Argentina
AM   Armenia
AS   American Samoa
AQ   Antarctica
TF   French Southern Territories
AG   Antigua and Barbuda
AU   Australia
AT   Austria
AZ   Azerbaijan
BI   Burundi
........

Please let me know how to fix it, I do not have a GUI on this install and I will prefer CLI utilities for accomplishing this.

Offline

#2 2019-01-06 16:04:30

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,314

Re: obfuscated dialog display with checkbox

Welcome to the Arch Linux forums. 

I do not see anything that is obfuscated, but your input is using white space as a delimiter and is breaking in the wrong places..  Try quoting styles such as United\ Arab\ Emirates or "United Arab Emirates"  in the input file.

Last edited by ewaller (2019-01-06 16:04:52)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2019-01-07 09:54:58

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

ewaller wrote:

Welcome to the Arch Linux forums. 

I do not see anything that is obfuscated, but your input is using white space as a delimiter and is breaking in the wrong places..  Try quoting styles such as United\ Arab\ Emirates or "United Arab Emirates"  in the input file.

Thanks for the pointer, I managed to accomplish this by adding line numbers at the end of each line with nawk, I am not sure why it needs a third column.

Offline

#4 2019-01-07 14:47:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,770
Website

Re: obfuscated dialog display with checkbox

garrym wrote:

I am not sure why it needs a third column.

Really?

man dialog wrote:

--checklist text height width list-height [ tag item status ] ...


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2019-01-07 15:32:39

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:
garrym wrote:

I am not sure why it needs a third column.

Really?

man dialog wrote:

--checklist text height width list-height [ tag item status ] ...

I referred to the third column in the text file that I am trying to serve thru dialog. I know --checklist text height width list-height and defined it earlier before using nawk '{print $0, FNR}' > myfile

Offline

#6 2019-01-07 15:42:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,770
Website

Re: obfuscated dialog display with checkbox

Yes, the text file should contain lines of each three tokens: tag, item, and status.  It seems you put a single status "off" at the end, but there needs to be one status per entry.

You will also face a problem catting from the file with spaces in the items - I don't know of a practical way to have dialog not break on those spaces.  If you put all the entries on the command line, you can just quote items with spaces, but that doesn't work when catting from a file.  For example, the following would work:

dialog ... --checklist "Choose Country ISO Codes:" 100 160 80 \
   AW   Aruba off \
   AF   Afghanistan off \
   AO   Angola off \
   AI   Anguilla off \
   AX   "Åland Islands" off

Note that there is an "off" status for each item that should be off.  Status is per item, not for the entire dialog, as each item can be either selected or not.

Last edited by Trilby (2019-01-07 15:46:35)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2019-01-07 15:42:30

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 154

Re: obfuscated dialog display with checkbox

@garrym
I think @Trilby was referring to

[ tag item status ]

.
The items are triples.
Edit: Too slow.

Last edited by schard (2019-01-07 15:42:49)

Offline

#8 2019-01-07 15:51:08

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:

Yes, the text file should contain lines of each three tokens: tag, item, and status.  It seems you put a single status "off" at the end, but there needs to be one status per entry.

No, those are the layout parameters and 'off' means no pre selection.  I used --file parameter instead of cat.

dialog --checklist "Please Select Alpha-2 ISO Codes:" 0 0 0 --file myfile

That worked for me.

Offline

#9 2019-01-07 15:52:27

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

schard wrote:

@garrym
I think @Trilby was referring to

[ tag item status ]

.
The items are triples.
Edit: Too slow.

Tag item status on or off.  The initial on/off state of each entry is specified by status.

Offline

#10 2019-01-07 16:04:59

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:

Yes, the text file should contain lines of each three tokens: tag, item, and status.  It seems you put a single status "off" at the end, but there needs to be one status per entry.

You will also face a problem catting from the file with spaces in the items - I don't know of a practical way to have dialog not break on those spaces.  If you put all the entries on the command line, you can just quote items with spaces, but that doesn't work when catting from a file.  For example, the following would work:

dialog ... --checklist "Choose Country ISO Codes:" 100 160 80 \
   AW   Aruba off \
   AF   Afghanistan off \
   AO   Angola off \
   AI   Anguilla off \
   AX   "Åland Islands" off

Note that there is an "off" status for each item that should be off.  Status is per item, not for the entire dialog, as each item can be either selected or not.

Your code won't work.  Put these values in text file and invoke dialog as I per my previous post -

AW  "Aruba" 1
AF  "Afghanistan" 2
AO  "Angola" 3
AI  "Anguilla" 4
AX  "Åland Islands" 5
AL  "Albania" 6
AD  "Andorra" 7
AE  "United Arab Emirates" 8
AR  "Argentina" 9
AM  "Armenia" 10
AS  "American Samoa" 11
AQ  "Antarctica" 12
TF  "French Southern Territories" 13
AG  "Antigua and Barbuda" 14
AU  "Australia" 15
AT  "Austria" 16
AZ  "Azerbaijan" 17
BI  "Burundi" 18
BE  "Belgium" 19
BJ  "Benin" 20
BQ  "Bonaire, Sint Eustatius and Saba" 21

Earlier, ewaller pointed at delimiter and helped me accomplish this. I am not sure why it works with line numbers at the end of each line. I understand your enthusiasm but you are off the mark.

Offline

#11 2019-01-07 16:15:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,770
Website

Re: obfuscated dialog display with checkbox

garrym wrote:

Your code won't work.

Yes, it does.  And most importantly if I change a couple of the "off"s to "on"s those items are selected when the dialog window comes up.  Each item can be initially either on or off.

Your use of --file also works, but the numbers are giberish, they are all treated as "off" by default (and you removed the extra "off" from the command line).  Change one of the numbers (or a couple) to "on" and see the results.

Last edited by Trilby (2019-01-07 16:18:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#12 2019-01-07 16:30:21

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:
garrym wrote:

Your code won't work.

Yes, it does.  And most importantly if I change a couple of the "off"s to "on"s those items are selected when the dialog window comes up.  Each item can be initially either on or off.

Your use of --file also works, but the numbers are giberish, they are all treated as "off" by default (and you removed the extra "off" from the command line).  Change one of the numbers (or a couple) to "on" and see the results.

The modified dialog command doesn't include off , the numbers aren't gibberish, try without numbers. When I find time later in the day I will populate the list with different encoding and use string manipulation for simplifying things. There are over 249 lines and it makes no sense to type all those lines in console.  Please try your method, take a screenshot and show me how it looks like.

Offline

#13 2019-01-07 16:31:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,770
Website

Re: obfuscated dialog display with checkbox

They are gibberish, read my post.  They are required to be there, I didn't say they shouldn't be.  That's my whole point which I've repeated several times: each line needs three entries, a tag, an item, and a status.  The numbers are gibberish in that they should be either "on" or "off", and all the numbers are just interpreted as equivalent to "off".  Seriously, read the man page.

Mine works, but apparently what isn't obvious which should be plainly obvious, is that the elipses were placeholders for all your other parameters.  In fact it works fine without all those other parameters.  But I really don't give a damn anymore, you are clearly quite disconnected from reality.  Do whatever you'd like.

Last edited by Trilby (2019-01-07 16:33:15)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#14 2019-01-07 16:39:36

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:

They are gibberish, read my post.  They are required to be there, I didn't say they shouldn't be.  That's my whole point which I've repeated several times: each line needs three entries, a tag, an item, and a status.  The numbers are gibberish in that they should be either "on" or "off", and all the numbers are just interpreted as equivalent to "off".  Seriously, read the man page.

I tried with off earlier but it didn't work.

Offline

#15 2019-01-07 17:03:43

garrym
Member
Registered: 2019-01-06
Posts: 9

Re: obfuscated dialog display with checkbox

Trilby wrote:

Mine works, but apparently what isn't obvious which should be plainly obvious, is that the elipses were placeholders for all your other parameters.  In fact it works fine without all those other parameters.  But I really don't give a damn anymore, you are clearly quite disconnected from reality.  Do whatever you'd like.

Already refined it and posted the modified dialog invocation. Thanks, anyway.

Offline

#16 2019-01-07 18:36:03

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 2,255

Re: obfuscated dialog display with checkbox

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

Board footer

Powered by FluxBB