fields.awk database

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#41 Post by Pete »

Latest version of fields2html attached (remove fake .zip).
Copy to /usr/sbin and set permissions.
Delete any previous versions you may have.

By placing it in /usr/sbin, it is accessible from anywhere when you call it when using it "manually" and fields.awk will also find it.
It's actually proven to be a handy general purpose text to html converter.

The latest version accepts a -q parameter (must be the second parameter) after the input text file.
This -q option suppresses any output to stdout and will just quietly convert your text file to html without asking you if you want to then open it.

Attached is also the latest modified version of fields.awk (again remove fake .zip) where it automatically calls fields2html to generate a txt and html version of your searches.
Fields.awk places these files in ~/Desktop directory.
Attachments
fields2html.zip
(2.04 KiB) Downloaded 187 times
fields.awk.zip
(10.84 KiB) Downloaded 180 times

cabbie0
Posts: 26
Joined: Thu 23 Jun 2016, 05:19
Location: British Columbia, Canada

fields2html script

#42 Post by cabbie0 »

Hi,

Congratulations Pete, that html conversion script seems to work fine in the fields.awk mod.
I like the approach of keeping the mods simple by calling the an outside script (such as fields2html or addcol) from within fields.awk, in order to keep the database script itself as true to the original as possible while still adding functionality.
This also seems in keeping with the basic Unix philosophy.

I have a question regarding your suggested placement of the fields2html script.
You recommend /usr/sbin but a regular user shouldn't be able to activate a script in /usr/sbin. Are you running fields.awk as root?
For a regular user I'd place the script in /usr/local/bin. That's what I did and it seemed to work fine.

Cheers

cabbie0
Posts: 26
Joined: Thu 23 Jun 2016, 05:19
Location: British Columbia, Canada

Differing terminal behavior on fields.awk search outputs

#43 Post by cabbie0 »

Hi,

Regarding my previous post indicating that links in a fields.awk search output should be "clickable" in some terminals but not others:

Note the following differences of behavior in 4 different terminals displaying the same fields.awk search output.
Case 1 = xterm
Case 2 = LXterminal
Case 3 = Xfce4-terminal
Case 4 = sakura

The images were taken with a digital camera to include the mouse-click drop down menus, since I don't see any way to include that with normal screen capture. Sorry for poor quality resulting from size reductions.

Hope this helps.
Attachments
DSC05145.jpg
Xterm: right-clicking a link in the search output has no effect. (Not much use)
(118.51 KiB) Downloaded 154 times
DSC05149.JPG
LXterminal: Right-clicking a link in the search output includes an option to copy URL, but no direct opening of the link. (Good but not quite there)
(224.17 KiB) Downloaded 156 times
DSC05148.JPG
Xfce4-terminal: Right-clicking a link in the search output includes an option to directly open the link. (Yes!)
(223.38 KiB) Downloaded 156 times
DSC05150.JPG
Sakura: Again, right-clicking a link in the search output includes an option to directly open the link. This time, the terminal is a standalone item. (Yes!)
(157.8 KiB) Downloaded 159 times

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

Re: Differing terminal behavior on fields.awk search outputs

#44 Post by mcewanw »

cabbie0 wrote:Hi,

Regarding my previous post indicating that links in a fields.awk search output should be "clickable" in some terminals but not others:
Hello Ian,

Just trying out your fields.awk database. Very nice to play with and a very useful and easy to customise commandline script.

I am using it in XenialDog, which is a Ubuntu 16.04 Xenial Xerus fully compatible system which has been special crafted by Fredx181 to be very "puppy-like" in use and size but fully apt/dpkg/synaptics capable:

http://www.murga-linux.com/puppy/viewtopic.php?t=106696

XenialDog doesn't have gawk installed by default, but your script seems to work fine so far simply by creating simlink gawk pointing to existing /usr/bin/awk (which turns out to itself actually be a symlink that ends up at /usr/bin/mawk...).

Main news is that XenialDog uses Roxterm by default and, in that terminal, right-clicking on url links in Roxterm allows either direct opening in browser or in copying to pasteboard. Great!
(EDIT: That's a facility provided by the terminal itself of course, rather than internally by fields.awk; any url seen in a Roxterm window, manually typed or created by any program output will offer the click-to-open functionality).

William

EDIT: of course, if using mawk instead of gawk proves problematic, I can always install gawk via apt or synaptics in XenialDog, but so far no problems anyway.
Last edited by mcewanw on Sun 26 Jun 2016, 08:04, edited 3 times in total.
github mcewanw

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#45 Post by greengeek »

Pete wrote:One can now convert a fields.awk database directly without using fields,awk or any manipulation.

Code: Select all

fields2html /path/to/database.txt
Hi Pete, I just gave this a try and it gave me the correct output (and asked me if i wanted the browser opened) but the urls do not appear as underlined. Do you think that might be something to do with the way my browser is configured? (see pic)

Also - after the browser displayed the output I couldnt tell what to do next with the terminal output so just did a ctrl C and the terminal closed - but so did both instances of Firefox that I had open at the time. (Just thought I'd mention that in case there is a way to only close the PID of the browser window that was started by the terminal rather than the original I already had open)
Attachments
browser_view.jpg
(18.95 KiB) Downloaded 145 times

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#46 Post by mcewanw »

Note: you can open underlined url links displayed in lxterminal by holding Ctrl key whilst left-clicking on the link if you have xdg-open on your system. To get xdg-open functionality in XenialDog, I first had to install the small xdg-utils package using:

Code: Select all

apt-get install xdg-utils
Also, you can apparently open links in urxvt if you first undertake the setup instructions as given here (I haven't tried this) Again seems to rely on xdg-open:

https://wiki.archlinux.org/index.php/Rx ... kable_URLs

EDIT: Apparently there is a way to enable clipboard support in xterm and clickable url links too (albeit complex triple click...), but again I've not tried this. Find the info in following:

https://lukas.zapletalovi.com/2013/07/h ... xterm.html

William

EDIT2: I've since installed sakura version 3.3.4 on XenialDog and it also now has an Open Link option on right-click. I didn't try it prior to installing xdg-utils, but I expect it needs the xdg-open facility provided by that too. EDIT3: It doesn't seem to need xdg-utils afterall (I tried it without).
Last edited by mcewanw on Sun 26 Jun 2016, 23:08, edited 4 times in total.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

Re: fields2html script

#47 Post by Pete »

cabbie0 wrote:Hi,

Congratulations Pete, that html conversion script seems to work fine in the fields.awk mod.
I like the approach of keeping the mods simple by calling the an outside script (such as fields2html or addcol) from within fields.awk, in order to keep the database script itself as true to the original as possible while still adding functionality.
This also seems in keeping with the basic Unix philosophy.

I have a question regarding your suggested placement of the fields2html script.
You recommend /usr/sbin but a regular user shouldn't be able to activate a script in /usr/sbin. Are you running fields.awk as root?
For a regular user I'd place the script in /usr/local/bin. That's what I did and it seemed to work fine.

Cheers
Hi cabbie0

Glad it's working well in other distros too.
As regards /usr/sbin versus /usr/local/bin, most people using Puppy run as root by default, however if you prefer /usr/local/bin and it works then it's fine too.

BTW as regards my mods, you can easily find them by searching for <pete_mod_start> which always precedes them.
Last edited by Pete on Sun 26 Jun 2016, 09:59, edited 1 time in total.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#48 Post by Pete »

greengeek wrote:Hi Pete, I just gave this a try and it gave me the correct output (and asked me if i wanted the browser opened) but the urls do not appear as underlined. Do you think that might be something to do with the way my browser is configured?
No, your URLs don't have // after the http: part.

They should be:

Code: Select all

http://www.somewebsite.com
or
https://www.anothersite.com
Screenshot below shows your DB with corrected URLs which are clickable.
Attachments
ScreenshotGK(1).jpg
(22.79 KiB) Downloaded 231 times
Last edited by Pete on Sun 26 Jun 2016, 08:58, edited 3 times in total.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

Re: Differing terminal behavior on fields.awk search outputs

#49 Post by Pete »

cabbie0 wrote:Hi,

Regarding my previous post indicating that links in a fields.awk search output should be "clickable" in some terminals but not others:
Nice list, will download all the text and pics and make a pdf document and post here.
It will come in handy as a quick reference of clickable links in different terminals.

@mcewanw

Great info too, will include it in the pdf as well.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#50 Post by greengeek »

Pete wrote:No, your URLs don't have // after the http: part.
Oh yes. Sorry. Corrected now but I get quite a different display format. Any idea what I'm doing differently to you? It's fine this way but just wondered why the difference.
Attachments
Clickable_now.jpg
(16.74 KiB) Downloaded 226 times

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#51 Post by Pete »

Hi greengeek

The difference is that I'm using fields.awk to generate the html automatically from a search and you are parsing the "raw" database file thru fields2html.
(I'm assuming you are using the latest fields.awk and fields2html and you have placed fields2html in /usr/sbin).

Either works as you have seen but you get different layouts.
This can actually be rather useful depending on how you want the output formatted.

cabbie0
Posts: 26
Joined: Thu 23 Jun 2016, 05:19
Location: British Columbia, Canada

Miscellaneous

#52 Post by cabbie0 »

@mcewanw
Hi William.
Interesting that Roxterm is another terminal example which has the link-opening option.
I tried it on Devuan and it works as you describe. It has a slightly different look from the standard dark terminals; nice.
Also, I think the reason you are seeing normal functionality without gawk installed is your symlink /usr/bin/awk -> /usr/bin/mawk.
Mawk has the extra functionality needed as does gawk.

Also very interesting regarding the CTRL-click trick for launching a link displayed in LXterminal. Ha!
I tried it with Xfce4-terminal and sakura, but it only worked for LXterminal.
Had the xdg-utils installed from something else apparently...


@Pete
Ok I wasn't aware that running as root was default in Puppy Linux. That explains the /usr/sbin location.
Obviously another preference thing ;)
And yes I noticed your use of tags (<pete_mod_start> .... <pete_mod_end>) to mark your code changes.
I like that; good documentation technique.

Cheers,
Ian

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#53 Post by greengeek »

I have attached a pet which creates a menu item for starting fields.awk and incorporates the modifications that I like so far. Seems really functional for me and I hope someone else finds it useful too.

This is not an officially sanctioned pet - just my testing phase. Comments appreciated.

Changes as follows:

- Incorporated Ian Forsyth's modification to allow automatic selection of the active database file whenever a new database file is created (instead of having the extra step of manual selection)
- Incorporated Pete's modification to allow .html file output as well as .txt file output (and offers to open browser)
- Changed Pete's mod slightly so that file output appears in /root instead of "/Desktop" directory which is not present in my Slacko derivative.
- Includes Pete's fields2html script.
- Changed wording of the question in "read_from" section asking user to supply name of output file. Wanted to prompt "no suffix required"
- Added a .desktop file placing fields.awk in Business menu (requires mini-modules.xpm icon which is already in Slacko)
- Added a wrapper script (fieldstart) alongside fields.awk and placed both in /usr/local/bin as per Ian's preferred location.

Note: I did not use the same method as Pete eg: <pete_mod_start> .... <pete_mod_end> to highlight my mods as I have occasionally noticed in the past that if I put extra lines in the wrong place it can upset some functionality (might have been in the middle of GTK tables or something that I did not understand at the time) - I didn't trust myself to get such tags in the right place so I have noted my changes in the blurb at the top of the script.

Hope it's ok to make these changes Ian - it is common in Puppyland to load extra programmes via pet and it can help other users' testing and troubleshooting too. I have used the suffix _gg to indicate that this is not an official pet - just my own version for testing. Let me know if you are not happy with anything here and I can take it down.
Attachments
fieldsawk_gg-0.1.pet
(5.82 KiB) Downloaded 232 times

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#54 Post by Pete »

@greengeek

Great, thanks for the pet, will make things much easier for others.
Does your pet copy fields2html to /usr/sbin as well?.

@cabbie0

A .pet is a Puppy Linux thing (I suppose equivalent to Debian's .deb).
Pets are actually tar.gzip files so you can change it to .tgz to view the contents but I doubt very much it will work in your distro as it has Puppy specific things like menu entries and such.
Screenshot attached.
Attachments
ScreenshotFgg.jpg
(48.21 KiB) Downloaded 163 times
Last edited by Pete on Sun 26 Jun 2016, 17:45, edited 3 times in total.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#55 Post by greengeek »

Pete wrote:Does your pet copy fields2html to /usr/sbin as well?.
No, at this stage I have left it alongside fields.awk in /usr/local/bin as that was Ian's preferred location and I hoped it was sensible to keep them all together.

I understand that may potentially cause issues with "path" but I don't know what is "standard" across the puppy range so I just tried it this way and it seems to work. Only tried with Slacko so far though.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#56 Post by Pete »

No worries greengeek.
Just after I posted, I downloaded your pet and noticed the /usr/local/bin which is fine.

cabbie0
Posts: 26
Joined: Thu 23 Jun 2016, 05:19
Location: British Columbia, Canada

Running fields.awk in FreeBSD

#57 Post by cabbie0 »

Hi guys,

Just a note that recently I did some experimenting with FreeBSD (an alternate unix clone for home computers) in response to concerns over the migration to systemd in most of the Linux distros, including my preferred Debian.
I installed FreeBSD on two older laptops [and Acer Aspire (Intel) and a HP G61 (AMD)] as well as on a separate hard-drive in my current desktop (ASUS motherboard).
In each case I found that fields.awk would run fine, so long as I selected the bash shell specifically.
This underscored the fact that which shell you use is also important.
In FreeBSD, the default shell is not bash, but rather sh, or sometimes csh.
Actually only csh is truly problematic. Fields.awk won't run in it at all.
In sh, or dash, it will run okay except for the "bold text" feature.

In summary, if you do find yourselves using another unix-like system (even a non-Linux one), you will likely still be able to use fields.awk. :)
Attachments
fields-bold.awk.zip
fields.awk with bold text highlighting feature
Note this will not work in sh or dash shells, only bash.
(10.43 KiB) Downloaded 224 times
fieldsawk_bold.jpg
Fields.awk with bold highlighting feature, running in LXterminal
(47.09 KiB) Downloaded 167 times

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#58 Post by Pete »

That is indeed interesting info cabbie0, many thanks.
I wonder if fields.awk will also run on:

1) a MAC, they have a weird version of awk or gawk or mawk or what ever it is they have.

2) Windows (under Cygwin)

3) A raspberry Pie, although they seem to also have a weird awk

and what would be really handy is to be able to run fields.awk on a rooted phone/tablet.

cabbie0
Posts: 26
Joined: Thu 23 Jun 2016, 05:19
Location: British Columbia, Canada

Pet "tarball"

#59 Post by cabbie0 »

@greengeek
No worries. I have no objections to any of this. Sounds awesome.
So you are using Slackware?

@Pete
Thank you for explaining what a .pet is. I was wondering about that.

Regarding /usr/local/bin for system-available executables:
Seems this should not be necessary for anyone using Puppy Linux if you are indeed all running bash as root by default.
That is, if path issues arise then your /usr/sbin default might be preferable.
But for anyone on an alternate distro operating by default as regular users with non-root privileges, files placed in /usr/sbin won't be seen as available unless they specifically log in as root or use su or sudo to launch fields.awk.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#60 Post by Pete »

cabbie0

Puppies are a bit of a mixed breed.
There is Slacko which is based on Slackware, then there is DebianDog, no explanation needed there and there are even some Puppies based on Ubuntu.
There could be others, not sure.
Then of course there are 32 and 64 bit version of some Puppies.

The link below should give you a better picture:

http://puppylinux.com/family-tree.html

Post Reply