Archive for May, 2019
Find files with errors
My students wanted a quick solution on how to find the log files that contain errors. That’s a simple line of code in Linux if you want any Oracle errors that start with ORA-
:
find $HOME/lab2 -type f | xargs grep -i ora\- |
It takes only a moment more to look for errors starting with ORA-
or PLS-
, like:
find $HOME/lab2 -type f | xargs grep -i -e ora\- -e pls\- |
The latter might return something like this:
contact_lab.txt:ORA-00904: "MEMBER_LAB_ID": invalid identifier contact_lab.txt:ORA-00942: table or view does not exist contact_lab.txt:ORA-00942: table or view does not exist member_lab.txt:ORA-02264: name already used by an existing constraint member_lab.txt:ORA-00955: name is already used by an existing object |
You can improve the error identification by identifying line numbers by adding -n
option, like:
find $HOME/lab2 -type f | xargs grep -in -e ora\- -e pls\- |
The latter might return something like this when there are two or more files:
contact_lab.txt:76:ORA-00904: "MEMBER_LAB_ID": invalid identifier contact_lab.txt:150:ORA-00942: table or view does not exist contact_lab.txt:157:ORA-00942: table or view does not exist member_lab.txt:75:ORA-02264: name already used by an existing constraint member_lab.txt:149:ORA-00955: name is already used by an existing object |
Unfortunately, the command raises an error when there aren’t any files found of with a qualified extension. It also fails to prepend the file name when there’s only one qualified file name. As a result of these deficiencies, I’ve written the following Bash shell script. I’ve opted to call it the .findErrors.bashrc
file name and deploy it in the user’s $HOME
directory.
#!/bin/bash # Assign any file filter to the ext variable. ext=${1} # Assign the extension or simply use a wildcard for all files. if [ ! -z ${ext} ]; then ext="*.${ext}" else ext="*" fi # Assign the number of qualifying files to a variable. fileNum=$(ls -l ${ext} 2>/dev/null | grep -v ^l | wc -l) # Evaluate the number of qualifying files and process. if [ ${fileNum} -eq "0" ]; then echo "[0] files exist." elif [ ${fileNum} -eq "1" ]; then fileName=$(ls ${ext}) find `pwd` -type f | grep -in ${ext} -e ora\- -e pls\- | while IFS='\n' read list; do echo "${fileName}:${list}" done else find `pwd` -type f | grep -in ${ext} -e ora\- -e pls\- | while IFS='\n' read list; do echo "${list}" done fi |
You can modify the errors()
function with or without a file extension to identify errors beginning with ORA-
or PLS-
in their log files. As always, I hope this helps those looking for a solution.
Convert JSON with PHP
Sometimes I get poorly thought or just naive questions. That is naive questions because they didn’t read the documentation or don’t understand the semantics of a given programming language. The question this time said they tried to implement what they found on a web page but their sample json_decode
function example failed after they followed directions.
Surprise, it didn’t fail because they followed directions. They overlooked part of the example because they didn’t understand how to read a nested array in PHP. The actual example sets up an array of JSON objects, then print_r
to read the Array
, but the student tried to read it in a foreach
loop. Naturally, their sample program raised an error because the base object was an Array
not a String
, and their target JSON object was nested inside the base Array
.
I rewrote the example file to simply convert a JSON structure to an associative array, as follow:
<?php // Assign a JSON object to a variable. $someJSON = '{"name":"Joe","moniker":"Falchetto"}'; // Convert the JSON to an associative array. $someArray = json_decode($someJSON, true); // Read the elements of the associative array. foreach ($someArray as $key =--> $value) { echo "[" . $key . "][" . $value . "]"; } ?> |
When you call the program, like this
php test.php |
It displays
[name][Joe][moniker][Falchetto] |
As always, I hope this helps those looking to display a JSON structure in PHP.
Chrome on Fedora 27
Installing Chrome wasn’t as easy just running the yum
utility. You need to download it from the following website.
rpm
utility to run it, you’ll get the following errors:
warning: google-chrome-stable_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEY error: Failed dependencies: /usr/bin/lsb_release is needed by google-chrome-stable-74.0.3729.131-1.x86_64 libappindicator3.so.1()(64bit) is needed by google-chrome-stable-74.0.3729.131-1.x86_64 liberation-fonts is needed by google-chrome-stable-74.0.3729.131-1.x86_64 |
- lab_release
- libappindicator3.so.1
- liberation-fonts
While the error message indicates you’re missing the libappindicator3.so.1
library, the required library is actually the libappindicator-gtk3
library. You can use the yum
utility to install the required library from the repository as the root
user.
The library you need is actually in the repository as libappindicator-gtk3
. You can use the yum
utility to install the required library.
yum install -y libappindicator-gtk3 Last metadata expiration check: 1:04:24 ago on Sat 04 May 2019 05:34:34 PM MDT. Dependencies resolved. ====================================================================================================================== Package Arch Version Repository Size ====================================================================================================================== Installing: libappindicator-gtk3 x86_64 12.10.0-16.fc27 fedora 41 k Installing dependencies: libdbusmenu-gtk3 x86_64 16.04.0-4.fc27 fedora 38 k libindicator-gtk3 x86_64 12.10.1-11.fc27 fedora 67 k Transaction Summary ====================================================================================================================== Install 3 Packages Total download size: 147 k Installed size: 382 k Downloading Packages: (1/3): libdbusmenu-gtk3-16.04.0-4.fc27.x86_64.rpm 63 kB/s | 38 kB 00:00 (2/3): libappindicator-gtk3-12.10.0-16.fc27.x86_64.rpm 65 kB/s | 41 kB 00:00 (3/3): libindicator-gtk3-12.10.1-11.fc27.x86_64.rpm 93 kB/s | 67 kB 00:00 ---------------------------------------------------------------------------------------------------------------------- Total 145 kB/s | 147 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : libindicator-gtk3-12.10.1-11.fc27.x86_64 1/3 Running scriptlet: libindicator-gtk3-12.10.1-11.fc27.x86_64 1/3 Installing : libdbusmenu-gtk3-16.04.0-4.fc27.x86_64 2/3 Running scriptlet: libdbusmenu-gtk3-16.04.0-4.fc27.x86_64 2/3 Installing : libappindicator-gtk3-12.10.0-16.fc27.x86_64 3/3 Running scriptlet: libappindicator-gtk3-12.10.0-16.fc27.x86_64 3/3 Verifying : libappindicator-gtk3-12.10.0-16.fc27.x86_64 1/3 Verifying : libdbusmenu-gtk3-16.04.0-4.fc27.x86_64 2/3 Verifying : libindicator-gtk3-12.10.1-11.fc27.x86_64 3/3 Installed: libappindicator-gtk3.x86_64 12.10.0-16.fc27 libdbusmenu-gtk3.x86_64 16.04.0-4.fc27 libindicator-gtk3.x86_64 12.10.1-11.fc27 Complete! |
While the error message indicates you’re missing the lab_release
library, the required library is actually the redhat-lsb-core
library. You can use the yum
utility to install the required library from the repository as the root
user.
yum install -y redhat-lsb-core Last metadata expiration check: 1:30:39 ago on Sat 04 May 2019 05:34:34 PM MDT. Dependencies resolved. ====================================================================================================================== Package Arch Version Repository Size ====================================================================================================================== Installing: redhat-lsb-core x86_64 4.1-36.fc27 fedora 42 k Installing dependencies: at x86_64 3.1.20-6.fc27 fedora 79 k mailx x86_64 12.5-25.fc27 updates 258 k ncurses-compat-libs x86_64 6.0-14.20170722.fc27 updates 321 k redhat-lsb-submod-security x86_64 4.1-36.fc27 fedora 20 k spax x86_64 1.5.3-10.fc27 fedora 212 k Transaction Summary ====================================================================================================================== Install 6 Packages Total download size: 932 k Installed size: 1.9 M Downloading Packages: (1/6): redhat-lsb-submod-security-4.1-36.fc27.x86_64.rpm 24 kB/s | 20 kB 00:00 (2/6): redhat-lsb-core-4.1-36.fc27.x86_64.rpm 48 kB/s | 42 kB 00:00 (3/6): at-3.1.20-6.fc27.x86_64.rpm 80 kB/s | 79 kB 00:00 (4/6): spax-1.5.3-10.fc27.x86_64.rpm 554 kB/s | 212 kB 00:00 (5/6): mailx-12.5-25.fc27.x86_64.rpm 1.1 MB/s | 258 kB 00:00 (6/6): ncurses-compat-libs-6.0-14.20170722.fc27.x86_64.rpm 903 kB/s | 321 kB 00:00 ---------------------------------------------------------------------------------------------------------------------- Total 479 kB/s | 932 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : mailx-12.5-25.fc27.x86_64 1/6 Installing : ncurses-compat-libs-6.0-14.20170722.fc27.x86_64 2/6 Running scriptlet: ncurses-compat-libs-6.0-14.20170722.fc27.x86_64 2/6 Installing : spax-1.5.3-10.fc27.x86_64 3/6 Running scriptlet: spax-1.5.3-10.fc27.x86_64 3/6 Installing : redhat-lsb-submod-security-4.1-36.fc27.x86_64 4/6 Installing : at-3.1.20-6.fc27.x86_64 5/6 Running scriptlet: at-3.1.20-6.fc27.x86_64 5/6 Installing : redhat-lsb-core-4.1-36.fc27.x86_64 6/6 Running scriptlet: redhat-lsb-core-4.1-36.fc27.x86_64 6/6 Running as unit: run-rca25c70a677d4866bb6056b31e1034c3.service Verifying : redhat-lsb-core-4.1-36.fc27.x86_64 1/6 Verifying : at-3.1.20-6.fc27.x86_64 2/6 Verifying : redhat-lsb-submod-security-4.1-36.fc27.x86_64 3/6 Verifying : spax-1.5.3-10.fc27.x86_64 4/6 Verifying : ncurses-compat-libs-6.0-14.20170722.fc27.x86_64 5/6 Verifying : mailx-12.5-25.fc27.x86_64 6/6 Installed: redhat-lsb-core.x86_64 4.1-36.fc27 at.x86_64 3.1.20-6.fc27 mailx.x86_64 12.5-25.fc27 ncurses-compat-libs.x86_64 6.0-14.20170722.fc27 redhat-lsb-submod-security.x86_64 4.1-36.fc27 spax.x86_64 1.5.3-10.fc27 Complete! |
The last missing library is liberation-fonts
, which you can also install from the repository with the yum
utility, like so as the root
user:
yum install -y liberation-fonts Last metadata expiration check: 2:01:27 ago on Sat 04 May 2019 05:34:34 PM MDT. Dependencies resolved. ====================================================================================================================== Package Arch Version Repository Size ====================================================================================================================== Installing: liberation-fonts noarch 1:1.07.4-10.fc27 updates 17 k Installing dependencies: liberation-narrow-fonts noarch 1:1.07.4-10.fc27 updates 208 k Transaction Summary ====================================================================================================================== Install 2 Packages Total download size: 225 k Installed size: 476 k Downloading Packages: (1/2): liberation-fonts-1.07.4-10.fc27.noarch.rpm 49 kB/s | 17 kB 00:00 (2/2): liberation-narrow-fonts-1.07.4-10.fc27.noarch.rpm 336 kB/s | 208 kB 00:00 ---------------------------------------------------------------------------------------------------------------------- Total 191 kB/s | 225 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : liberation-narrow-fonts-1:1.07.4-10.fc27.noarch 1/2 Installing : liberation-fonts-1:1.07.4-10.fc27.noarch 2/2 Running scriptlet: liberation-fonts-1:1.07.4-10.fc27.noarch 2/2 Verifying : liberation-fonts-1:1.07.4-10.fc27.noarch 1/2 Verifying : liberation-narrow-fonts-1:1.07.4-10.fc27.noarch 2/2 Installed: liberation-fonts.noarch 1:1.07.4-10.fc27 liberation-narrow-fonts.noarch 1:1.07.4-10.fc27 Complete! |
You can install the Chrome browser with the following command as the root
user:
yum install -y google-chrome-stable_current_x86_64.rpm Last metadata expiration check: 2:08:09 ago on Sat 04 May 2019 05:34:34 PM MDT. Dependencies resolved. ====================================================================================================================== Package Arch Version Repository Size ====================================================================================================================== Installing: google-chrome-stable x86_64 74.0.3729.131-1 @commandline 56 M Transaction Summary ====================================================================================================================== Install 1 Package Total size: 56 M Installed size: 196 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: google-chrome-stable-74.0.3729.131-1.x86_64 1/1 Installing : google-chrome-stable-74.0.3729.131-1.x86_64 1/1 Running scriptlet: google-chrome-stable-74.0.3729.131-1.x86_64 1/1 error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable) error: /tmp/google.sig.KSJ5OI: key 1 import failed. error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable) error: /tmp/google.sig.KSJ5OI: key 2 import failed. Redirecting to /bin/systemctl start atd.service Running as unit: run-rcb32925ea21c401da74f536a222563ef.service Verifying : google-chrome-stable-74.0.3729.131-1.x86_64 1/1 Installed: google-chrome-stable.x86_64 74.0.3729.131-1 Complete! |
[11346:11357:0504/212207.077855:ERROR:ssl_client_socket_impl.cc(946)] handshake failed; returned -1, SSL error code 1, net_error -200 context mismatch in svga_sampler_view_destroy |
I upgraded the code in Fedora 27 because the Firefox browser wasn’t processing HTML Select tags correctly. After the upgrade of all fixes, the Firefox browser fails to let you use tabs to query other web pages. I shutdown Firefox, restarted it successfully, and took note that the liberation-fonts
package was the problem. The tab processing issue occurred because I applied liberation-fonts
package without restarting Firefox. Both Firefox and Chrome use the liberation-fonts
package for displaying text.
You should run Chrome with the following command-line syntax to avoid the warning errors triggered by an existing bug:
google-chrome 2>/dev/null &
It would display a web page, like:
I hope this helps those looking for a solution.