Technology Tales

Adventures & experiences in contemporary technology

Automating FTP I: UNIX and Linux

11th April 2008

Having got tired of repeated typing in everything at the prompt of an interactive command line FTP session and doing similar things via the GUI route, I started to wonder if there was a scripting alternative and, lo and behold, I found it after a spot of googling. There are various opportunities for its extension such as prompting for username and password instead of the risky approach of including them in a script or cycling through a directory structure but here’s the foundation stone for such tinkering anyway:

HOSTNAME='ftp.server.host'
USER='user'
PSSWD='password'
REP_SRC='source_directory'
REP__DEST='destination_directory'
FILENAME='*'

rm -rf log_file.tmp

cd "${REP_DEST}"

ftp -i -n -v <<EndFTP >>log_file.tmp 2>>log_file.tmp
open ${HOSTNAME}
user ${USER} ${PSSWD}
prompt
cd "${REP_SRC}"
mget "${FILENAME}"
EndFTP

cd ~

Automating FTP II: Windows

15th April 2008

Having thought about automating command line FTP on UNIX/Linux, the same idea came to me for Windows too and you can achieve much the same results, even if the way of getting there is slightly different. The first route to consider is running a script file with the ftp command at the command prompt (you may need %windir%system32ftp.exe to call the right FTP program in some cases):

ftp -s:script.txt

The contents of script are something like the following:

open ftp.server.host
user
password
lcd destination_directory
cd source_directory
prompt
get filename
bye

It doesn’t take much to turn your script into a batch file that takes the user name as its first input and your password as its second for sake of enhanced security and deletes any record thereof for the same reason:

echo open ftp.server.host >  script.txt
echo %1 >> script.txt
echo %2 >> script.txt
echo cd htdocs >> script.txt
echo prompt >> script.txt
echo mget * >> script.txt
echo bye >> script.txt
%windir%system32ftp.exe -s:script.txt
del script.txt

The feel of the Windows command line (in Windows 2000, it feels very primitive but Windows XP is better and there’s PowerShell now too) can leave a lot to be desired by someone accustomed to its UNIX/Linux counterpart but there’s still a lot of tweaking that you can do to the above, given a bit of knowledge of the Windows batch scripting language. Any escape from a total dependence on pointing and clicking can only be an advance.

Some nice things coming through…

22nd May 2008

While everyone is making good use of WordPress 2.5.x, development continues apace for future releases of the popular blogging platform and there are some goodies coming through on the functionality front. Google Gears are being brought into play for speeding up the administration dashboard; this started out being more prominent before being made more unobtrusive. The other big change has been an overhaul of the theme gallery and, if the theme is compatible, an overview facility has been added too. So WordPress is being tweaked and improved in the background to make 2.6 an interesting release.

Losing formatting with Windows copying and pasting

25th July 2008

Copy and pasting between Windows programs can cause unwanted formatting to be carried over. Copying text from Internet Explorer into Outlook is one example of this that I see a lot and Word to Word does it too. A trick that I picked up for avoiding this copying of formatting comes from a while back: copying into Notepad and pasting from there. Doing the copy/paste shuffle in that way strips off the formatting baggage and alllows the default formatting for the particular destination to be applied. There may be other and slicker ways to do this but what I have described works for me.

An alternative use for Woopra

4th August 2008

Google Analytics is all very fine with its once a day reporting cycle but the availability of real time data dose have its advantages. WordPress.com’s Stats plugin goes some way to serving the need but Woopra trumps it in every way apart from a possible overkill in the amount of information that it makes available. The software may be in the beta phase and it does crash from time to time but its usefulness remains more than apparent.

One of its uses is seeing if there are people visiting your website at a time when you might be thinking of making a change like upgrading WordPress. Timing such activities to avoid a clash is a win-win situation: a better experience from your visitors and more reliable updates for you. After all, it’s very easy to make a poor impression and an unreliable site will do that faster than anything else so it’s paramount that your visitors do not get on the receiving end of updates, even if they are all for the better.

Out of memory at line: 56

28th May 2009

This is an error that I have started to see a lot in the last few weeks. First, it was with Piwik and latterly with WordPress.com Stats. For the record, I have never seen it on up to date systems but always with IE6 and at page unloading time. The CPU usage hits 100% before the error is produced and that has had me blaming JavaScript in error; it isn’t the cause of all ills. In fact, the cause seems to be a bug in a certain release of Adobe Flash 9 but I am of the opinion that the inclusion of certain features in a Flash movie are needed to trigger it too. I don’t have the exact details of this but WordPress.com Stats worked without fault until a recent update and that is what is making me reach the conclusion that I have. That observation is making me wonder whether we are coming to a point where Flash compatibility is something that needs to factored into the use of the said technology in a website or web application. Updating Flash will solve the problem on the client but it might be better if it wasn’t triggered on the server side either.

Sometimes, things do get missed…

18th September 2009

Being a user of Textpattern, I should have a vested interested in any developments in that venerable web platform. However, the latest release came out at the end of August unbeknownst to me and that’s with an entry on the Dev Blog. Those blog entries come irregularly so that might have been how I missed it but there were other things going on in my life like the installation of new windows in my house and weekends spent in Scotland and Ireland.

Still, the whole release was more low key than, say, a new version of WordPress where many would be shouting how important the upgrade would be and with messages turning up on blog administration screens too. There may be good reason for this given the recent problems experienced by those who fail to keep up with progress. Of course, WordPress is a major target for unwanted attention so it’s best to keep your wits about you. The low key nature of Textpattern might be an asset when it comes to warding off miscreants and its greater compatibility with more technically minded folk may help security too. Saying all of that may be pure speculation but you only have to look at the world of operating systems to see how the idea came into my mind.

A later posting on the Txp blog tells you about the new goodies available in release 4.2.0 but here’s a short selection to whet your appetite: themes for the administration area, multiple sites and new tags. Upgrading proved painless though I did try it out on an offline version of the microsite where I use Textpattern before making a move on its online counterpart. All went smoothly but it’s alway best to look before you leap or a site rebuild might be in order and no one needs that.

Seeing how things develop

7th October 2009

One of the things that I do out of curiosity and self-interest is to keep tabs on what is happening with development versions of software that I use. It is for this reason that I always have a development version of WordPress on the go so as to ensure that the next stable version doesn’t bring my blog to its knees. There have been contributions from my own self to the development effort, mainly in the form of bug reports with the occasional bug fix too.

In the same vein, I have had a development version of Ubuntu installed in a VirtualBox virtual machine. There have been breakages and reinstallations along the way when an update results in disruption but it is intriguing too to see how a Linux distribution comes to fruition. In the early days of Karmic Koala (9.10), everything was thrown together more loosely and advances looked less obvious. It is true to say the ext4 file systems support was already in place but the interface looked like a tweaked version of the standard GNOME desktop. Over time, the desktop has been customised and boot messages hidden out of sight. Eye candy like new icons and backgrounds have begun to entice while other features such as an encrypted home folder, Software Store and Ubuntu One came into place. Installation screens became slicker and boot times reduced. All of this may seem incremental but revolutions can break things and you only have to look at the stuttering progress of Windows to see that. Even with all of these previews, I still plan to do a test run of the final revision of 9.10 before committing to putting it in place on my main home PC. Bearing the scars of misadventures over the years has taught me well.

Windows development is a less open process but I have been partial fo development versions there too. In fact, beta and release candidate installations of Windows 7 have convinced me to upgrade from Windows XP for those times when a Windows VM needs to fired up in anger. A special offer has had me ordering in advance and sitting back and waiting. With my Windows needs being secondary to my Linux activities, I am not so fussed about taking my time and I have no intention of binning Windows XP just yet anyway.

The trouble with all of this previewing is that you get buffeted by the ongoing development. That is very true of Ubuntu 9.10 and has been very much part and parcel of the heave that brought WordPress 2.7 into being last year. Things get added and then removed as development tries to fins that sweet spot or a crash results and you need to rebuild things. It is small wonder that you are told not to put unfinished software on a production system. Another consequence might be that you really question why you are watching all of this and come to decide that what you already have is a place of safety in comparison to what’s coming. So far, that has never turned out to be true but there’s no harm in looking before you leap either.

Moving application title bar buttons on GNOME desktops

6th March 2010

Screenshot-Configuration Editor

A recent look at how Ubuntu 10.04 development is getting on confronted me with an interface situation to which I am not accustomed: title bar buttons at the left. The usual combination of buttons for maximisation, minimisation and closure were there in their usual order but at the left of the window. While this is the where you find them on OS X, I prefer the Windows convention and placed them to the right again.

To achieve that end, I ran gconf-editor from the command line using my usual user account (not sudo; that doesn’t seem to work) and made my way to apps -> metacity -> general. Once there, I sought out the button_layout property and moved the colon in the value from the left to the right. In other words, I started with this:

maximize,minimize,close:

and changed it to this (note the position of the colon in the actual string):

:maximize,minimize,close

If you ever find yourself wanting to change things from the Windows convention to the Apple one, just reverse what I did. As an aside, you also can swap the button order too if you like. After all, it’s just a text field that you can edit and the screen immediately refreshes when you hit the Return key after completing the edit.

As a more general observation, if Ubuntu 10.04 does come out using the OS X convention for title bar button placement, I could see others like wanting it changed back and that’s why I am sharing it here. Surprising users in this way, especially after the 9.10 release’s attracting some adverse comments, would not be all that advisable. The issue may be easy to address, but that’s small comfort when you release how easily users are discouraged.

Nevertheless, 10.04 is an LTS release and what I have seen so far looks polished; there may be no splash screen at boot and shutdown time for what I am running (I am sticking with acquiring upgrades every so often instead of periodic re-installation from a new disk image) but that’s a minor matter.

For the sake of not turning over the apple cart, I may have left off VirtualBox Additions and things look steady enough so far. In fact, I am writing these words using Firefox 3.6 on there. Accompanying that is OpenOffice 3.2, but things do not look so different apart from these, a reassuring observation. While there may be an emphasis on purple in the colour scheme at the time of writing, that could change yet. 9.10’s course had plenty of that so I am willing to be patient. After all, there’s more than a month to go, yet before the final cut is available for general use.

Carrying out a hard reset of a home KVM switch

20th March 2017

During a recent upgrade from Linux Mint 18 to Linux Mint 18.1 on a secondary machine, I ran into bother with my Startech KVM (keyboard, video, mouse and audio sharing) switch. The PC failed to recognise the attachment of my keyboard and mouse so an internet search began.

Nothing promising came from it apart from resetting the KVM switch. In other words, the solution was to turn it off and back on again. That was something that I did try without success. What I had overlooked was that there USB connections to PC’s that fed the device with a certain amount of power and that was enough to keep it on.

Unplugging those USB cables as well as the power cable was needed to completely switch off the device. That provided the reset that I needed and all was well again. Otherwise, I would have been baffled enough to resort to buying a replacement KVM switch so the extra information avoided a purchase that could have cost in the region of £100. In other words, a little research had saved me money.

  • All the views that you find expressed on here in postings and articles are mine alone and not those of any organisation with which I have any association, through work or otherwise. As regards editorial policy, whatever appears here is entirely of my own choice and not that of any other person or organisation.

  • Please note that everything you find here is copyrighted material. The content may be available to read without charge and without advertising but it is not to be reproduced without attribution. As it happens, a number of the images are sourced from stock libraries like iStockPhoto so they certainly are not for abstraction.

  • With regards to any comments left on the site, I expect them to be civil in tone of voice and reserve the right to reject any that are either inappropriate or irrelevant. Comment review is subject to automated processing as well as manual inspection but whatever is said is the sole responsibility of the individual contributor.