in DevOps

Playing with the perl RTM client.

I began playing with a perl-based RememberTheMilk command line tool today from http://www.rutschle.net/rtm/.  There aren’t any RPMs of it that I found, so I ended up building some.  This is what I had to do to get it to the stage of at least working.

:;  sudo cpan2rpm WebService::RTMAgent

-- cpan2rpm - Ver: 2.028 --
Upgrade check
Fetch: HTTP

-- module: WebService::RTMAgent --
Using cached URL: http://search.cpan.org//CPAN/authors/id/R/RU/RUTSCHLE/WebService-RTMAgent-0.5_1.tar.gz
Tarball found - not fetching
Metadata retrieval
Tarball extraction: [/home/tcampbell/src/rpm/SOURCES/WebService-RTMAgent-0.5_1.tar.gz]

Can't locate object method "interpolate" via package "Pod::Text" at /usr/bin/cpan2rpm line 525.
cannot remove path when cwd is /tmp/yFnnvY7DA3/WebService-RTMAgent-0.5_1 for /tmp/yFnnvY7DA3:  at /usr/share/perl5/File/Temp.pm line 902
-- Done --

But, I ran into this dumb perl interpolate bug. Turns out that cpan2rpm has an issue with newer versions of perl where Pod::Text no longer has this method. Changing Pod::Text to Pod::Parser in cpan2rpm allowed this to succeed.

sudo cpan2rpm WebService::RTMAgent  --no-sign

-- cpan2rpm - Ver: 2.028 --
Upgrade check
Fetch: HTTP

-- module: WebService::RTMAgent --
Using cached URL: http://search.cpan.org//CPAN/authors/id/R/RU/RUTSCHLE/WebService-RTMAgent-0.5_1.tar.gz
Tarball found - not fetching
Metadata retrieval
Tarball extraction: [/home/tcampbell/src/rpm/SOURCES/WebService-RTMAgent-0.5_1.tar.gz]
Generating spec file
SPEC: /home/tcampbell/src/rpm/SPECS/WebService-RTMAgent.spec
Generating package
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.xs7L3d
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ cd /home/tcampbell/src/rpm/BUILD
+ rm -rf WebService-RTMAgent-0.5_1
+ /usr/bin/gzip -dc /home/tcampbell/src/rpm/SOURCES/WebService-RTMAgent-0.5_1.tar.gz
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd WebService-RTMAgent-0.5_1
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ chmod -R u+w /home/tcampbell/src/rpm/BUILD/WebService-RTMAgent-0.5_1
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.sKaxgX
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ cd WebService-RTMAgent-0.5_1
+ grep -rsl '^#!.*perl' .
+ grep -v '.bak$'
+ xargs --no-run-if-empty /usr/bin/perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)'
+ CFLAGS='-O2 -g -march=i386 -mtune=i686'
++ /usr/bin/perl -MExtUtils::MakeMaker -e ' print qq|PREFIX=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr| if $ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '
+ /usr/bin/perl Makefile.PL
Checking if your kit is complete...
Looks good
WARNING: Setting ABSTRACT via file 'lib/WebService/RTMAgent.pm' failed
 at /usr/share/perl5/ExtUtils/MakeMaker.pm line 603
Writing Makefile for WebService::RTMAgent
+ /usr/bin/make
cp lib/WebService/RTMAgent.pm blib/lib/WebService/RTMAgent.pm
Manifying blib/man3/WebService::RTMAgent.3pm
+ /usr/bin/make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t ....... 1/1 # Testing WebService::RTMAgent 0.5_1, Perl 5.010001, /usr/bin/perl
t/00-load.t ....... ok   
t/auth.t .......... frobbed -- getting token
t/auth.t .......... 1/7 frobbed -- getting token
token token
t/auth.t .......... ok   
t/boilerplate.t ... ok   
t/init.t .......... ok   
t/pod-coverage.t .. skipped: Test::Pod::Coverage 1.08 required for testing POD coverage
t/pod.t ........... ok   
t/requests.t ...... 1/12 request:
POST http://www.rememberthemilk.com/services/rest/
Content-Type: application/x-www-form-urlencoded

method=rtm.tasks.add&nam=adding&api_key=key&auth_token=10438&timeline=114114&api_sig=3340edd30a22e9b2c67ff206283d0b67


response:
HTTP/1.1 200 OK
Connection: keep-alive
Date: Mon, 24 Dec 2007 11:49:10 GMT
Server: nginx/RTM
Vary: Accept-Encoding
Content-Type: text/xml; charset="utf-8"
Client-Date: Mon, 24 Dec 2007 11:50:39 GMT
Client-Peer: 75.126.232.204:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Keep-Alive: timeout=300







t/requests.t ...... ok     
t/undo.t .......... ok   
All tests successful.

Test Summary Report
-------------------
t/boilerplate.t (Wstat: 0 Tests: 3 Failed: 0)
  TODO passed:   1-3
Files=8, Tests=35,  0 wallclock secs ( 0.05 usr  0.01 sys +  0.59 cusr  0.06 csys =  0.71 CPU)
Result: PASS
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.7ZK9SK
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ cd WebService-RTMAgent-0.5_1
+ '[' /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386 '!=' / ']'
+ rm -rf /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386
++ /usr/bin/perl -MExtUtils::MakeMaker -e ' print $ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr| : qq|DESTDIR=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386| '
+ make prefix=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr exec_prefix=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr bindir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/bin sbindir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/sbin sysconfdir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/etc datadir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share includedir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/include libdir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/lib libexecdir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/libexec localstatedir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/var sharedstatedir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/var/lib mandir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/man infodir=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/info install DESTDIR=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386
Manifying blib/man3/WebService::RTMAgent.3pm
Installing /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/local/share/perl5/WebService/RTMAgent.pm
Installing /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/local/share/man/man3/WebService::RTMAgent.3pm
Appending installation info to /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/lib/perl5/perllocal.pod
+ cmd=/usr/share/spec-helper/compress_files
+ '[' -x /usr/share/spec-helper/compress_files ']'
+ cmd=/usr/lib/rpm/brp-compress
+ '[' -x /usr/lib/rpm/brp-compress ']'
+ /usr/lib/rpm/brp-compress
+ '[' -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ']'
+ find /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386 -name perllocal.pod -o -name .packlist -o -name '*.bs'
+ xargs -i rm -f '{}'
+ find /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr -type d -depth -exec rmdir '{}' ';'
+ /usr/bin/perl -MFile::Find -le '
    find({ wanted => \&wanted, no_chdir => 1}, "/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386");
    print "%doc  Changes README";
    for my $x (sort @dirs, @files) {
        push @ret, $x unless indirs($x);
        }
    print join "\n", sort @ret;

    sub wanted {
        return if /auto$/;

        local $_ = $File::Find::name;
        my $f = $_; s|^\Q/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386\E||;
        return unless length;
        return $files[@files] = $_ if -f $f;

        $d = $_;
        /\Q$d\E/ && return for reverse sort @INC;
        $d =~ /\Q$_\E/ && return
            for qw|/etc /usr/man /usr/bin /usr/share|;

        $dirs[@dirs] = $_;
        }

    sub indirs {
        my $x = shift;
        $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs;
        }
    '
+ '[' -z WebService-RTMAgent-0.5_1-filelist ']'
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: perl-WebService-RTMAgent-0.5_1-1.noarch
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.25mTCz
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ cd WebService-RTMAgent-0.5_1
+ DOCDIR=/home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/doc/perl-WebService-RTMAgent-0.5_1
+ export DOCDIR
+ rm -rf /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/doc/perl-WebService-RTMAgent-0.5_1
+ /bin/mkdir -p /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/doc/perl-WebService-RTMAgent-0.5_1
+ cp -pr Changes README /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386/usr/share/doc/perl-WebService-RTMAgent-0.5_1
+ exit 0
Provides: perl(WebService::RTMAgent) = 0.5
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(VersionedDependencies) <= 3.0.3-1
Requires: perl(Carp) perl(Digest::MD5) perl(LWP::UserAgent) perl(XML::Simple) perl(strict) perl(vars)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386
Wrote: /home/tcampbell/src/rpm/SRPMS/perl-WebService-RTMAgent-0.5_1-1.src.rpm
Wrote: /home/tcampbell/src/rpm/RPMS/noarch/perl-WebService-RTMAgent-0.5_1-1.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.xrdBo2
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ cd WebService-RTMAgent-0.5_1
+ '[' /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386 '!=' / ']'
+ rm -rf /home/tcampbell/src/rpm/BUILDROOT/perl-WebService-RTMAgent-0.5_1-1.i386
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.eKyVlR
+ umask 022
+ cd /home/tcampbell/src/rpm/BUILD
+ rm -rf WebService-RTMAgent-0.5_1
+ exit 0
RPM: /home/tcampbell/src/rpm/RPMS/noarch/perl-WebService-RTMAgent-0.5_1-1.noarch.rpm
SRPM: /home/tcampbell/src/rpm/SRPMS/perl-WebService-RTMAgent-0.5_1-1.src.rpm
-- Done --

Sweet! now we can install it.

:;  sudo rpm -ivh /home/tcampbell/src/rpm/RPMS/noarch/perl-WebService-RTMAgent-0.5_1-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:perl-WebService-RTMAgen########################################### [100%]

Great. Now we grab the rtm command from the website.

:;  wget http://www.rutschle.net/rtm/rtm-0.5.gz
--2011-01-04 13:47:20--  http://www.rutschle.net/rtm/rtm-0.5.gz
Resolving www.rutschle.net... 82.235.147.6
Connecting to www.rutschle.net|82.235.147.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4212 (4.1K) [application/x-gzip]
Saving to: `rtm-0.5.gz'

100%[===========================================================================>] 4,212       24.3K/s   in 0.2s    

2011-01-04 13:47:21 (24.3 KB/s) - `rtm-0.5.gz' saved [4212/4212]

:; gunzip rtm-0.5.gz

Now, we run it and ... boom.

:;  ./rtm-0.5 
Use of uninitialized value in concatenation (.) or string at /usr/local/share/perl5/WebService/RTMAgent.pm line 312.
98: Login failed / Invalid auth token
Use of uninitialized value at /usr/local/share/perl5/WebService/RTMAgent.pm line 368

Looks like we need to get an auth token. Looking inside the script, it appears you have to run rtm with the --authorise option. This creates a URL that you put in the browser to authorize the client with RememberTheMilk. After that was done, I can now run rtm from the command line.

:;  ./rtm-0.5 
frobbed -- getting token
token [my token]
0: Turabelle photos
1: do something incredible
2: Ticket to manage notification of changes to bobqueue files.
3: Create ticket to Place bob configs under puppet/avn
4: Rebound payment

Looks like that frobbed/token header go away after the first run.

Now I'm good to go with hitting RememberTheMilk from the command line. Sweet!

Travis Campbell
Staff Systems Engineer at ghostar
Travis Campbell is a seasoned Linux Systems Engineer with nearly two decades of experience, ranging from dozens to tens of thousands of systems in the semiconductor industry, higher education, and high volume sites on the web. His current focus is on High Performance Computing, Big Data environments, and large scale web architectures.