While using associative arrays, I run into this little issue using this sample KSH93 code:
#!/bin/ksh93u+
function scmp {
typeset -A IPAA;
# Load First File.
for KEY in $(cat 1.rip); do
IPA1[KEY]=1;
done
# Load Second File.
for KEY in $(cat 2.rip); do
IPA2[KEY]=1;
done
};
function main {
scmp;
};
main;
Which resulted in this error:
[root@mbpc bin]# ./a.ksh
./a.ksh[23]: main[21]: scmp: line 10: 192.81.0.250: arithmetic syntax error
[root@mbpc bin]#
The real change to address was here and it was to set the IPA1 and IPA2 to associative array type (Had typeset -A IPAA erronously):
#!/bin/ksh93u+
function scmp {
typeset -A IPA1;
typeset -A IPA2;
# Load First File.
(( CNT = 0 ));
for KEY in $(cat 1.rip); do
(( CNT++ ));
IPA1[“${KEY}”]=1;
print "CNT=|$CNT|";
done
# Load Second File.
for KEY in $(cat 2.rip); do
IPA2[“”KEY]=1;
done
};
function main {
scmp;
};
main;
which naturally fixed the problem. Of course, the above could be generated for any number of reasons however in this case, it was the typeset lines above:
Cheers,
TK
December 6th, 2012 | Posted in NIX Posts | No Comments
When assigning values to an associative array in KSH, it's important to note the significance of the $ value:
# typeset -A ABCD; $(( ABCD[“moi”]=0 )); $(( ABCD[“moi”]++ )); $(( ABCD[“moi”]++ )); $(( ABCD[“moi”]++ )); print ${ABCD[“moi”]};
/bin/ksh93u+: 0: not found [No such file or directory]
/bin/ksh93u+: 0: not found [No such file or directory]
/bin/ksh93u+: 1: not found [No such file or directory]
/bin/ksh93u+: 2: not found [No such file or directory]
3
#
The solution to the above, is of couse to use this logic (dropping the $ in front of the (( … )) statements):
# typeset -A ABCD; (( ABCD[“moi”]=0 )); (( ABCD[“moi”]++ )); (( ABCD[“moi”]++ )); (( ABCD[“moi”]++ )); print ${ABCD[“moi”]};
3
#
Cheers,
TK
December 6th, 2012 | Posted in NIX Posts | No Comments
Here's are an example of a random number generator in KSH or it's newer counterpart KSH93. For this post, we'll use the latest KSH from AT&T Labs:
-
Generate a random set of integers between 0 – 256 and use them to create a random set of IP type entries:
#!/bin/ksh93u+
for (( KEY=0; KEY < 1000000000; KEY++ )); do
print $(( RANDOM / 128 ))"."$(( RANDOM / 128 ))"."$(( RANDO^C/ 128 ))"."$(( RANDOM / 128 ));
done
The purpose of the above is to obtain a random set of entries (IP like) for testing purposes in other logic including testing regular expressions. RANDOM, in this case generates a number between 0 and 32768 and when divided by 128, will print out the intiger part of the equation. To assign a random number a statement similar to MVAR=$RANDOM; can also be used.
Cheers,
TK
December 6th, 2012 | Posted in NIX Posts | No Comments
The current theme does not natively support menus, but you can use the "Custom Menu" widget to add any menus you create here to the theme's sidebar.
“Your theme supports 0 menus. Select which menu appears in each location”
Reading further on the following pages, we can enable the menus using these functions:
http://codex.wordpress.org/Function_Reference/register_nav_menu
http://codex.wordpress.org/Function_Reference/register_nav_menus
To fix this using the above, in your wordpress theme (create the files if they don't exist.):
header.php (Right after body tag)
<?php wp_nav_menu('menu=Header'); ?>
functions.php (Right at the very top)
<?php
if (function_exists('add_theme_support')) {
register_nav_menus( array( $location => $description ) );
}
?>
CSS Styles come later and can be applied
After that, you should see:
Your theme supports 1 menu. Select which menu you would like to use.
and should be able to create and customize your menus using the wordpress admin panel for your blog. Here are some alternatives how to enable and apply CSS as well to style your menus:
Read the rest of this entry »
December 2nd, 2012 | Posted in NIX Posts | 3 Comments
After enabling the wordpress WP Super Cache and the HTML Minifi plugin for the WP Super Cache plugin (That's right, a plugin for a plugin) I get empty pages on /localhost/wp/ (Or https://www.microdevsys.com/wp/) which obviously isn't so good for the readers. So i download the plugin to my local server LAMP installation and test it there. Thankfully I get the same results. (Thankfully because otherwise I'd have a very difficult time debugging this thing through my web host who has limited access.)
/var/log/httpd/error_log
[Fri Nov 30 20:52:13 2012] [warn] Cannot get media type from 'x-mapp-php5'
[Fri Nov 30 20:52:13 2012] [error] [client ::1] PHP Warning: require_once(/var/www/html/wp/wp-content/plugins/wp-super-cache/plugins/min/lib/Minify/HTML.php): failed to open stream: No such file or directory in /var/www/html/wp/wp-content/plugins/wp-super-cache/plugins/WPSCMin.php on line 125, referer: http://localhost/wp/wp-admin/options-general.php?page=wpsupercache&tab=plugins
[Fri Nov 30 20:52:13 2012] [error] [client ::1] PHP Fatal error: require_once(): Failed opening required '/var/www/html/wp/wp-content/plugins/wp-super-cache/plugins/min/lib/Minify/HTML.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/wp/wp-content/plugins/wp-super-cache/plugins/WPSCMin.php on line 125, referer: http://localhost/wp/wp-admin/options-general.php?page=wpsupercache&tab=plugins
[Fri Nov 30 20:52:13 2012] [error] [client ::1] PHP Fatal error: Call to a member function get() on a non-object in /var/www/html/wp/wp-includes/cache.php on line 113, referer: http://localhost/wp/wp-admin/options-general.php?page=wpsupercache&tab=plugins
And in my /var/log/messages, this one:
localhost – – [30/Nov/2012:20:54:48 -0500] "GET /wp/ HTTP/1.1" 500 – "http://localhost/wp/wp-admin/options-general.php?page=wpsupercache&tab=plugins" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.26) Gecko/20120216 Red Hat/3.6.26-1.el6_2 Firefox/3.6.26 AlexaToolbar/alxf-2.17"
Read the rest of this entry »
November 30th, 2012 | Posted in NIX Posts | 1 Comment
Sure enough we baught outselves a Nexus 7 tablet and of course what's a PC, miniature or not, without some sort of web access. My router is setup with MAC address filtering which prevented initial connection unless I get the MAC address of the device to begin with. Unfortunately, Nexus 7 won't let you into the settings until you do an initial setup.
In this case, I've disabled the MAC address filtering on my DD-WRT'd TP-LINK router temporarily (Let's remember, I still have WPA2 security with SSID broadcase disabled so I'm fine to do that.) Once connected, I checked that my connection is fine from my other wireless devices before trying to connect from the Nexus 7. With everything else working, google Nexus 7 went through it's paces and I was finally able to get in on to the device and get my MAC:
Read the rest of this entry »
November 30th, 2012 | Posted in NIX Posts | 1 Comment
WP Super Cache sometimes prints out this message. Cliking on the link revealed a 403 forbidden error wehn we did try.
Test your cached website by clicking the test button below.
Fetching https://www.microdevsys.com/wp/ to prime cache: OK
Fetching first copy of https://www.microdevsys.com/wp/: OK (1.html)
Fetching second copy of https://www.microdevsys.com/wp/: OK (2.html)
The pages do not match! Timestamps differ or were not found!
Things you can do:
-
Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.
-
Enable logging on the Debug page here. That should help you track down the problem.
-
You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.
Read the rest of this entry »
November 30th, 2012 | Posted in NIX Posts | No Comments
Google, I love that company but sometimes it puzzles me. I'll search for:
ckeditor links.js getSelectedLink
but google returns this link:
http://ckeditor.com/forums/CKEditor-3.x/Tutorial-how-modify-Links-Plugin-link-cms-pages
(HINT: There's nothing on that page for getSelectedLink, not even in the source code of the page) but what I needed was:
https://gist.github.com/3940239
but that doesn't appear in any of the search results. So how did I get to that? Well, here's how and it's not directly through google search results unfortunately:
Read the rest of this entry »
November 29th, 2012 | Posted in NIX Posts | No Comments
While setting up my LAMP configuration on my HTPC, I get this error while trying to replicate my hosting environment for a future site upgrade:
[error] [client ::1] File does not exist: /var/www/html/wp/download-rpm-package-using-yum-without-installing, referer: http://localhost/wp/
[error] [client ::1] File does not exist: /var/www/html/wp/how-to-find-the-mac-address-of-an-ethernet-or-wireless-card, referer: http://localhost/wp/
No matter what I tried, I couldn't get the links to work getting a 404 Not Found instead:
Not Found
The requested URL /wp/how-to-find-the-mac-address-of-an-ethernet-or-wireless-card/ was not found on this server.
Read the rest of this entry »
November 18th, 2012 | Posted in NIX Posts | No Comments
To find the MAC address of an ethernet or wireless card is generally straight forward for straight forward configurations. The MAC address is a unique identifier for every NIC (Network Interface Card) that uniquely identifies that card amongst all others.
There's several commands that can be used for this depending on your network configuration and setup. The basic command to use for this is ifconfig (Equivalent of netstat -ie):
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 1C:6F:65:3F:FC:14
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:339061 errors:0 dropped:0 overruns:0 frame:0
TX packets:183764 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:82692563 (78.8 MiB) TX bytes:121295829 (115.6 MiB)
Interrupt:32 Base address:0x4000
However once the network configuration becomes a bit more complex, this just won't do:
Read the rest of this entry »
November 11th, 2012 | Posted in NIX Posts | 1 Comment