Why doesn’t mget and mdelete play nice together?

One of my colleagues needed a shell script which should:

  1. connect to an external system via FTP
  2. change to a remote directory
  3. get all the files in the directory to local machine
  4. and delete all the files in the remote directory

The ftp commands mget and mdelete can be used to retrieve and delete multiple files respectively. And the code snippet would be:
do_ftp()
{
rm -f $FPTLOG
ftp -n -v <remote_host> <<FTP >$FTPLOG 2>&1
user <user> <password>
cd  $REMOTE_DIR
lcd $LOCAL_DIR
mget *.txt
mdelete *.txt
bye
FTP
}

This should do the job, right? Unfortunately it doesn’t. mget works, but the mdelete afterwards isn’t triggering at all when I checked vsftpd.log.

I managed to save the day by putting a harmless command in between (looks like they need a mediator!).

mget ZCNT_RECON_FBL1N_*.txt
ls         #Needed this for mdelete to work
mdelete ZCNT_RECON_FBL1N_*.txt

Geeks, any explanation on why this happens?

ExMan – the super simple personal expense manager

Being a bachelor; I stay with my long term (college) friends. When my colleagues get to know we all guys happily live together, most of the time I hear a “wow”. And we have a cook who prepares delicious food [most of the time ;-) ], and we have a lot of common expense together, plus occasional/frequent personal expense things.

And yes, I dislike “Accounting”, and I hate keeping track of pennies spilt here and there. At the end of the month, I usually am at a loss, and I don’t care too much either. But I know I had to bookkeep something, but I detest that old fashioned “double entry bookkeeping”. I don’t want to care what are my assets, what are my liabilities, what is the liquid cash I have, and where to debit/credit, general ledger, blah, blah…

And I’ve been using GNote, the note taking application, for the purpose. But it needed manual calculation in the end anyway.

Few days back I realized that I need something better as I don’t want to sum all those items, meanwhile exclude some personal expenses or money lent to some guy. And I decided that it’s time to create a shiny new, uber-simple expense manager (which knows only how to add and/or exclude some entries).

The design concerns, in the order of importance, were:

  1. Should be lightweight, and should consume less resources
  2. Minimal external dependency
  3. Maintainable, clean design and clean code

Which resulted in some of the design choices:

  1. No database backend, instead a simple file backing store. The file structure is very simple, hence items can be easily added/removed/modified with a text editor as well.
  2. Qt4 framework for development, which makes ExMan a cross platform application
  3. (At least close to) Model-View-Controller architecture

It was exciting to develop on Qt4 platform, QtCreator and QtAssistant are awesome. Had fun with Signals/Slots, QTableWidget, QCalendarWidget, setCheckedState, SelectionModel,… learn by exploring.

And, without further ado, I present to thee, ExMan, the super simple personal expense/accounting manager:

ExMan

The Monthly Amount shows the total of all expenses, and the Excluded Amount shows the total of items excluded (personal items and other things).

ExMan source tar ball and RPM are available in Sourceforge.net project page.

Meiga – lightweight and easy content server for desktop

Once in a while, I need to share files with other computers in the network. But I don’t do it every day, so I am reluctant to setup a 1)Web server, 2) Samba server, 3) NFS server. Most of the time, accessing a windows share in a Windows computer fails – I can meddle with the Samba/Firewall setup and troubleshoot, but it usually ends up in vain. Further, you need to be root to add folders as Samba shares. I usually do scp over the other GNU/Linux machines, or give the other Non-GNU/Linux guy a copy of pscp and ask him to do an scp.

Well, what about a naive user, who just wants to share his files to his buddy sitting next to him? There are not too many easy tools I knew of, so I decided to weigh my options. And I found these candidates:

1. Giver – a very intuitive, and easy file sharing tool. You can simply share the files with computers that have giver installed. See it in action here. The cons:

  • Dependency on Mono. I always purge Mono out of my installation.
  • Client side needs to install Giver.

2. iFolder. Again, Mono, and client-server.

3. Dropbox. Feature rich. Cons:

  • Need to have dropbox account, need internet connection.
  • Client side also needs to install it.

4. Meiga. Lightweight, easy to use content server for desktop. It uses a lightweight web server protocol with libsoup. As and when required, just fire it up, and add the folders you want to share. The best thing – no need to install anything on the client side – the shared files can be accessed using a web browser.

So I decided to try it out on Fedora 11. Unfortunately, the developer provided only .deb files for Debian/Ubuntu, and there was no source tar ball. But there was a git repository, which I cloned, and created source tar ball out of it. Meddled with it to figure out the correct way to build and to find the precise build requirements. Build is based on autotools, and intltool. Then created a SPEC file and built the RPM.

While testing, I found out that Meiga couldn’t find any internal IP address. Investigated a bit, but strace, dbus-monitor etc didn’t help much. Then I contacted Enrique, the upstream developer and over the past week, we brainstormed together. Meiga gets the internal IP from a utility shell script – “/usr/bin/fwlocalip“, which internally uses the “/sbin/ip” and a little sed and grep to chop it. The problem with Fedora was that “ip” is in “/sbin” instead of “/bin” as in Ubuntu, and the PATH setting was not correct. So now the script is fixed to have better PATH environment variable setting, and Meiga works like a charm. Meanwhile, I requested Enrique to produce source tar ball also, and he kindly did so.meiga

Just fire up Meiga as a normal user, add the folders you want to share, and give the link “http://<your_ip_address&gt;:8001/<Share>/” to your friend and tell him to access using a web browser. That’s it – oh, make sure your firewall allows incoming connection to port 8001: iptables -A INPUT -p tcp --dport 8001 -j ACCEPT

Now I’ve filed a review request in the RedHat bugzilla to include Meiga. Hopefully someone will review it and I’ll fix any issues present, and I look forward to get Meiga into Fedora packages. Meanwhile, you can find the RPMs here.