How to Use CHMOD in Kasablanca

Kasablanca is a GUI FTP client, which I regularly use. Today, I needed to change the permissions on a folder to allow writing by the web server. After trying for a long time to do it in kasablanca, I found the solution: At the command-line, write:

$ lftp -u tim ftp.example.com
Password:
lftp tim@ftp.example.com:~> cd the/directory
lftp tim@ftp.example.com:the/directory> chmod 777 the_file

How to Drop All Tables in SQL Dump File

I am currently moving a WordPress blog from one server to another. In the process, I messed up the MySQL database transportation, resulting in some tables being created, and some rows being inserted. It would not be possible to simply run the SQL dump files again, since that would result in duplicate rows. This was easy to fix with some commandline and perl magic, though. The file containing all SQL statements is called wordpress-dump.sql (in this example).

First, find the names of all tables:

$ grep -E '^CREATE TABLE' wordpress-dump.sql
CREATE TABLE `cat_visibility` (
CREATE TABLE `comments` (
CREATE TABLE `links` (
CREATE TABLE `movie_ratings` (
CREATE TABLE `options` (
CREATE TABLE `photopress` (
CREATE TABLE `postmeta` (
CREATE TABLE `posts` (
CREATE TABLE `pp_cats` (
CREATE TABLE `sk2_logs` (
CREATE TABLE `sk2_spams` (
CREATE TABLE `term_relationships` (
CREATE TABLE `term_taxonomy` (
CREATE TABLE `terms` (
CREATE TABLE `usermeta` (
CREATE TABLE `users` (

Next, reformat those lines into DROP queries.

$ grep -E '^CREATE TABLE' wordpress-dump.sql | perl -pe 's/CREATE/DROP/; s/ *\($/;/;'

Now, you won’t have to change those by hand!

Failure to Install GD with CPAN: LDS/GD-2.35.tar.gz

I decided to install the GD image library for Perl on my working station, and as usual, using CPAN. However, after running install GD, I was faced with an error.

make: *** [GD.o] Error 1
  LDS/GD-2.35.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Failed during this command:
 LDS/GD-2.35.tar.gz                           : make NO

Unable to find the cause, I turned to apt-get, which installed GD without any problems.

$ sudo apt-cache search libgd perl 
libgd-gd2-perl - Perl module wrapper for libgd - gd2 variant
libgd-graph-perl - Graph Plotting Module for Perl 5
libgd-text-perl - Text utilities for use with GD
ruby1.8 - Interpreter of object-oriented scripting language Ruby 1.8
calamaris - log analyzer for Squid or Oops proxy log files
libgd-barcode-perl - Library to create barcode images (GD::Barcode)
libgd-gd1-noxpm-perl - Perl module wrapper for libgd (old version against GD 1.8.x)
libgd-gd1-perl - Perl module wrapper for libgd (old version against GD 1.8.x)
libgd-gd2-noxpm-perl - Perl module wrapper for libgd - gd2 variant without XPM support
libgd-graph3d-perl - Create 3D Graphs with GD and GD::Graph
libgd-perl - Perl module wrapper for libgd
libgd-securityimage-perl - Security image (captcha) generator.
libgdk-pixbuf-perl - Perl module for the gdkpixbuf library
$ sudo apt-get install libgd-perl

Done!

How to Upload Files Recursively on Linux Command-Line

Yesterday, I was transferring a blog from one server to another. I had SSH access to the server which the blog was moving from, and FTP access to the one which it was moved to. The simple solution in this situation is to use a command-line FTP client to simply upload everything. I tried, but encountered a problem.

Using the native ftp command, which comes with virtually every Linux distribution, I found the mput (multiple put) command. However, trying to use it with wild-cards didn’t work, since only the files in the base directory were uploaded. Trying things like mput */* only resulted in strange errors about existing files not existing. I went to look for a new text-based FTP client, which would be usable through SSH, and found lftp, which apparently was installed as default on my system.

lftp has a handy mirror command, similar to the wget –mirror option. Adding the -R (reverse) argument to mirror, recursive uploading became a piece of cake. Just do mirror -R when in the correct local and remote directories.

FireStats iconAnvänder FireStats