One step closer to world domination
Unix
perl-Net-SSLeay dependency error when installing Memcached with yum
Dec 3rd
Today while configuring another production CentOS 5.5 machine I ran into a problem where memcached refused to install.
[root@localhost ~]# yum install memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* rpmforge: apt.sw.be
rpmforge | 1.1 kB 00:00
rpmforge/primary | 2.2 MB 00:01
rpmforge 10361/10361
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package memcached.i386 0:1.4.5-1.el5.rf set to be updated
--> Processing Dependency: perl(AnyEvent) for package: memcached
--> Processing Dependency: perl(AnyEvent::Socket) for package: memcached
--> Processing Dependency: perl(AnyEvent::Handle) for package: memcached
--> Processing Dependency: libevent-1.1a.so.1 for package: memcached
--> Processing Dependency: perl(YAML) for package: memcached
--> Processing Dependency: perl(Term::ReadKey) for package: memcached
--> Running transaction check
---> Package compat-libevent-11a.i386 0:3.2.1-1.el5.rf set to be updated
---> Package perl-AnyEvent.noarch 0:5.240-1.el5.rf set to be updated
--> Processing Dependency: perl(JSON::XS) >= 2.2 for package: perl-AnyEvent
--> Processing Dependency: perl(JSON) >= 2.09 for package: perl-AnyEvent
--> Processing Dependency: perl(EV) >= 3.05 for package: perl-AnyEvent
--> Processing Dependency: perl(Guard) >= 1.02 for package: perl-AnyEvent
--> Processing Dependency: perl(Net::SSLeay) >= 1.33 for package: perl-AnyEvent
---> Package perl-TermReadKey.i386 0:2.30-3.el5.rf set to be updated
---> Package perl-YAML.noarch 0:0.71-1.el5.rf set to be updated
--> Running transaction check
---> Package perl-AnyEvent.noarch 0:5.240-1.el5.rf set to be updated
--> Processing Dependency: perl(Net::SSLeay) >= 1.33 for package: perl-AnyEvent
---> Package perl-EV.i386 0:3.9-1.el5.rf set to be updated
--> Processing Dependency: perl(common::sense) for package: perl-EV
---> Package perl-Guard.i386 0:1.021-1.el5.rf set to be updated
---> Package perl-JSON.noarch 0:2.17-1.el5.rf set to be updated
---> Package perl-JSON-XS.i386 0:2.27-1.el5.rf set to be updated
--> Running transaction check
---> Package perl-AnyEvent.noarch 0:5.240-1.el5.rf set to be updated
--> Processing Dependency: perl(Net::SSLeay) >= 1.33 for package: perl-AnyEvent
---> Package perl-common-sense.i386 0:3.0-1.el5.rf set to be updated
--> Finished Dependency Resolution
perl-AnyEvent-5.240-1.el5.rf.noarch from rpmforge has depsolving problems
--> Missing Dependency: perl(Net::SSLeay) >= 1.33 is needed by package perl-AnyEvent-5.240-1.el5.rf.noarch (rpmforge)
Error: Missing Dependency: perl(Net::SSLeay) >= 1.33 is needed by package perl-AnyEvent-5.240-1.el5.rf.noarch (rpmforge)
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
CentOS’s yum repository doesn’t have the latest perl-Net-SSLeay and perl-IO-Socket-SSL packages that are required by memcached. I did some Googling to find that others were experiencing a similar problem without resolution. Here’s the simple fix:
First, remove the old perl modules. Then download and install the newer versions that memcached requires.
rpm-e perl-Net-SSLeay-1.30-4.fc6
rpm -e perl-IO-Socket-SSL-1.01-1.fc6
wget http://packages.sw.be/perl-Net-SSLeay/perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm
wget http://packages.sw.be/perl-Net-SSLeay/perl-Net-SSLeay-1.36-1.el5.rfx.x86_64.rpm
wget http://packages.sw.be/perl-IO-Socket-SSL/perl-IO-Socket-SSL-1.34-1.el5.rfx.noarch.rpm
rpm -i perl-Net-SSLeay-1.36-1.el5.rfx.x86_64.rpm
rpm -i perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm
rpm -i perl-IO-Socket-SSL-1.34-1.el5.rfx.noarch.rpm
Now you should be able to install memcached without error.
yum -y install memcached
If you experience an error removing either of the packages then you can try greping to see if you have other versions installed.
rpm -qa | grep perl-Net-SSLeay
and
rpm -qa | grep perl-IO-Socket-SSL
Facebook-Status-2.0 announced!
Feb 10th
I have updated my original Facebook status script to work with Facebook 2.0.
Why is this interesting? Until recently the Facebook Developer Platform didn’t allow the changing of user status messages. This does and can be implemented in other utilities, which I may do in the future. Enjoy!
Bash Examples
Nov 23rd
A while ago a friend was taking an entry level Unix programming class and asked me to help him study. I came up with some sample problems for him. Here are my solutions:
The first is a program that will allow a user to input as many numbers as the user wants (999 as the choice that ends the user input). The program will then output the highest number, the lowest number, the sum of all the numbers, and the average number.
#!/bin/bash COUNT=0 echo -n "Enter a number (999 to quit): " while read NUM; do # Set initials if [ $COUNT -eq 0 ]; then HIGHEST=$NUM LOWEST=$NUM SUM=$NUM fi # If 999 is entered, break out if [ $NUM -eq 999 ]; then break else # See if inputted number is the highest number if [ $NUM -gt $HIGHEST ]; then HIGHEST=$NUM fi # See if inputted number is the lowest number if [ $NUM -lt $LOWEST ]; then LOWEST=$NUM; fi # Calculate sum SUM=$(($SUM+$NUM)) echo -n "Enter another number (999 to quit): " fi COUNT=$(($COUNT+1)) done AVERAGE=$(($SUM/$COUNT)) echo "Highest number: $HIGHEST" echo "Lowest number: $LOWEST" echo "Sum of the numbers: $SUM" echo "Average of the numbers: $AVERAGE"
The second program is a number guessing game. The computer picks a number from 0-60 then allows the user to guess at the number until the user gets it right. The program gives the user a hint on whether they should guess a higher or lower number.
#!/bin/bash RAN=$((RANDOM%60)) COUNTER=1 echo -n "I've guessed a number between 0-60, what is it? " while read GUESS; do if [ $GUESS -eq $RAN ]; then break; else echo if [ $GUESS -lt $RAN ]; then echo -n "Nope, try a higher number: " else echo -n "Nope, try a lower number: " fi fi COUNTER=$((COUNTER+1)) done echo echo "Yep, good job! It took you $COUNTER tries to guess correctly."
The third program allows a user to type in a number, then the program will either count up to the number provided by the user or count down from that number. In addition, a menu lets the user choose which counter they wish to use. In both cases that counter will either count down to 0, or start counting from 0.
#!/bin/bash echo -n "Enter a number: "; read NUM echo -n "Enter U to count up to $NUM and D to count down to 0: "; read CHOICE case $CHOICE in 'u'|'U') COUNTER=0 while [ $COUNTER -le $NUM ]; do echo $COUNTER COUNTER=$(($COUNTER+1)) done ;; 'd'|'D') while [ $NUM -ge 0 ]; do echo $NUM; NUM=$(($NUM-1)) done ;; *) echo "Error: You entered an invalid argument." esac
The last program asks the user if they want to add, subtract, multiply or divide two user inputted numbers. Then the program outputs the sum of number 1 and number 2, the difference of number 1 and number 2, the product of number 1 and number 2, and the quotient of number 1 and number 2
This program will run until the user wants to quit. Also, if the user puts in a 0 as the second number, we let the user know that if they choose divide that a division by zero error will occur.
#!/bin/bash while true; do echo "Please enter two numbers (type 'q' to quit): " echo -n "Number 1: " read NUM1 if [ $NUM1 == "q" ]; then exit; fi echo -n "Number 2: " read NUM2 echo -n "Enter (a) to add, (s) to subtract, (m) to multiply, or (d) to divide these numbers: " read OPERATION case $OPERATION in a) echo "The sum of $NUM1 and $NUM2 is: $(($NUM1+$NUM2))" ;; s) echo "The difference of $NUM1 and $NUM2 is: $(($NUM1-$NUM2))";; m) echo "The product of $NUM1 and $NUM2 is: $(($NUM1*$NUM2))" ;; d) if [ $NUM2 -eq 0 ]; then echo "You can't divide by 0, a division by zero error will occur." else echo "The quotient of $NUM1 and $NUM2 is: $(($NUM1/$NUM2))" fi ;; esac done
Newest LiveJournal Images
Nov 24th
This script displays the newest images posted by LiveJournal users. The script is pretty basic and simply parses a feed from LiveJournal.
You can view it in action here: http://mattdanger.net/lj/ (Warning: Some images may be NSFW!)
The code:
<?php $n = 5; // Maximum is 250 $referrer = 'http://example.com'; // Your site $email = 'user@example.com'; // Your email if ($fp = fsockopen('livejournal.com', 80)) { fputs($fp, "GET /stats/latest-img.bml HTTP/1.0rn" . "Host: www.livejournal.comrn" . "User-Agent: " . $referrer . "; " . $email . "rnrn"); $data = ''; while(!feof($fp)) { $data .= fgets($fp); } fclose($fp); preg_match_all("<recent-image img='([^']+)' url='([^']+)' />", $data, $out); for ($i = 0; $i < $n; $i++) { echo '<a href="' . $out[2][$i] . '"><img border="0" src="' . $out[1][$i] . '" /></a><br /><br />' . "n"; } } else { echo "Connecting to LiveJournal failed."; } ?>
As an aside, if you’re a LiveJournal user and don’t want your images posted to the public feed you can go to your command console and type “set latest_optout yes”.










