mysql/mariadb error 35

I’ve had a problem with mysql failing to start with error 35 in the log file:

InnoDB: Unable to lock ./ibdata1, error: 35
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.

What to do? Google and you get a lot of Linux people saying that the answer is to reboot the box. Hmm. Well you don’t have to.

What causes the error is mysqld crashing, usually when system resources are exhausted. Rebooting will, indeed, unlock ibdata1 but so will killing the process that locks it. Yet the server isn’t running, so how can this be? Well actually part of it is – just not the part the service manager sees.

Run “ps -auxww | grep mysql” and you’ll find a few more. Send them a kill, wait for it to work and then restart. Obviously you can only do this and expect it to work if you’ve sorted out the resource problem.

Using ddrescue to recover data from a USB flash drive

If you’re in the data recovery, forensics or just storage maintenance business (including as an amateur) you probably already know about ddrescue. Released about twenty years ago by Antonio Diaz Diaz, it was a big improvement over the original concept dd_rescue from Kurt Garloff in 1999. They copy disk images (which are just files in Unix) trying to get as much data extracted when the drive itself has faults.

If you’re using Windows rather than Unix/Linux then you probably want to get someone else to recover your data. This article assumes FreeBSD.

The advantage of using either of these over dd or cp is that they expect to find bad blocks in a device and can retry or skip over them. File copy utilities like dd ignore errors and continue, and cp will just stop. ddrescue is particularly good at retrying failed blocks, and reducing the block size to recover every last readable scrap – and it treats mechanical drives that are on their last legs as gently as possible.

If you’re new to it, the manual for ddrescue can be found here. https://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html

However, for most use cases the command is simple. Assuming the device you want to copy is /dev/da1 and you’re calling it thumbdrive the command would be:

ddrescue /dev/da1
thumbdrive.img thumbdrive.map

The device data would be stored in thumbdrive.img, with ongoing state information stored in thumbdrive.map. This state information is important, as it allows ddrescue to pick up where it left off.

However, ddrescue was written before USB flash drives (pen drives, thumb drives or whatever). That’s not to say it doesn’t work, but they have a few foibles of their own. It’s still good enough that I haven’t modified ddrescue base code to cope, but by using a bit of a shell script to do the necessary.

USB flash drives seem to fail in a different way to Winchester disks. If a block of Flash EPROM can’t be read it’s going to produce a read error – fair enough. But they have complex management software running on them that attempts to make Flash EPROM look like a disk drive, and this isn’t always that great in failure mode. In fact I’ve found plenty of examples where they come across a fault and crash rather than returning an error, meaning you have to turn them off and on to get anything going again (i.e. unplug them and put them back in).

So it doesn’t matter how clever ddrescue is – if it hits a bad block and the USB drive controller crashes the it’s going to be waiting forever for a response and you’ll just have come reset everything manually and resume. One of the great features of ddrescue is that it can be stopped and restarted at any time, so continuing after this happens is “built in”.

In reality you’re going to end up unplugging your USB flash drive many times during recovery. But fortunately, it is possible to turn a USB device off and on again without unplugging it using software. Most USB hardware has software control over its power output, and it’s particularly easy on operating systems like FreeBSD to do this from within a shell script. But first you have to figure out what’s where in the device map – specifically which device represents your USB drive in /dev and which USB device it is on the system. Unfortunately I can’t find a way of determining it automatically, even on FreeBSD. Here’s how you do it manually; if you’re using a version of Linux it’ll be similar.

When you plug a USB storage device into the system it will appear as /dev/da0 for the first one; /dev/da1 for the second and so on. You can read/write to this device like a file. Normally you’d mount it so you can read the files stored on it, but for data recovery this isn’t necessary.

So how do you know which /dev/da## is your media? This easy way to tell is that it’ll appear on the console when you first plug it in. If you don’t have access to the console it’ll be in /var/log/messages. You’ll see something like this.

Jun 10 17:54:24 datarec kernel: umass0 on uhub5
kernel: umass0: <vendor 0x13fe USB DISK 3.0, class 0/0, rev 2.10/1.00, addr 2> on usbus1
kernel: umass0 on uhub5
kernel: umass0: on usbus1
kernel: umass0: SCSI over Bulk-Only; quirks = 0x8100
kernel: umass0:7:0: Attached to scbus7
kernel: da0 at umass-sim0 bus 0 scbus7 target 0 lun 0
< USB DISK 3.0 PMAP> Removable Direct Access SPC-4 SCSI device
kernel: da0: Serial Number 070B7126D1170F34
kernel: da0: 40.000MB/s transfers
kernel: da0: 59088MB (121012224 512 byte sectors)
kernel: da0: quirks=0x3
kernel: da0: Write Protected
Please generate and paste your ad code here. If left empty, the ad location will be highlighted on your blog pages with a reminder to enter your code. Mid-Post

So this is telling us that it’s da0 (i.e /dev/da0)

The hardware identification is “<vendor 0x13fe USB DISK 3.0, class 0/0, rev 2.10/1.00, addr 2> on usbus1” which means it’s on USB bus 1, address 2.

You can confirm this using the usbconfig utility with no arguments:

ugen5.1:  at usbus5, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
...snip...
ugen1.1: at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2: at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (300mA)

There it is again, last line.

usbconfig has lots of useful commands, but the ones we’re interested are power_off and power_on. No prizes for guessing what they do. However, unless you specify a target then it’ll switch off every USB device on the system – including your keyboard, probably.

There are two ways of specifying the target, but I’m using the -d method. We’re after device 1.2 so the target is -d 1.2

Try it and make sure you can turn your USB device off and on again. You’ll have to wait for it to come back online, of course.

There are ways of doing this on Linux by installing extra utilities such as hub-ctrl. You may also be able to do it by writing stuff to /sys/bus/usb/devices/usb#/power/level” – see the manual that came with your favourite Linux distro.

The next thing we need to do is provide an option for ddrescue so that it actually times out if the memory stick crashes. The default is to wait forever. The –timeout=25 or -T 25 option (depending on your optional taste) sees to that, making it exit if it hasn’t been able to read anything for 25 seconds. This isn’t entirely what we’re after, as a failed read would also indicate that the drive hadn’t crashed. Unfortunately there’s no such tweak for ddrescue, but failed reads tend to be quick so you’d expect a good read within a reasonable time anyway.

So as an example of putting it all into action, here’s a script for recovering a memory stick called duracell (because it’s made by Duracell) on USB bus 1 address 2.

#!/bin/sh
while ! ddrescue -T 25 -u /dev/da0 duracell.img duracell.map
do
echo ddrescue returned $?
usbconfig -d 1.2 power_off
sleep 5
usbconfig -d 1.2 power_on
sleep 15
echo Restarting
done

A few notes on the above. Firstly, ddrescue’s return code isn’t defined. However, it appears to do what one might expect so the above loop will drop out if it ever completes. I’ve set the timeout for time since last good read to 25 seconds, which seems about right. Turning off the power for 5 seconds and then waiting for 15 seconds for the system to recognise it may be a bit long – tune as required. I’m also using the -u option to tell ddrescue to only go forward through the drive as it’s easier to read the status when it’s always incrementing. Going backwards and forwards makes sense with mechanical drives, but not flash memory.

Aficionados of ddrescue might want to consider disabling scraping and/or trimming (probably trimming) but I’ve seen it recover data with both enabled. Data recovery is an art, so tweak away as you see fit – I wanted to keep this example simple.

Now this system isn’t prefect. I’m repurposing ddrescue, which does a fine job on mechanical drives, to recover data from a very different animal. I may well write a special version for USB Flash drives but this method does actually work quite well. Let me know how you get on.

Having a good argument

I’ve seen all sorts of stuff on forums about how to process command line argument in C or C++. What a load of fuss and bother. There’s a standard getopt() function in the ‘C’ library, similar to the shell programming command, but it’s not great.

The main problem with getopt() is that it produces its own error message. Although this saves you the trouble, it can be a bit user unfriendly for the user, especially when things get complex. For example, you might have mutually exclusive arguments and want to print out a suitable message. That said, it’ll work most of the time.

Here’s a page showing a good explanation for the GCC version, whcih is pretty standard.

Example of Getopt (The GNU C Library)

But rolling your own is not hard. Here’s a skeleton I use. It’s pretty self-explanatory. My rules allow single options (e.g. -a -b) or combined options (e.g. -ab), or any mixture. “–” ends options, meaning subsequent arguments are going to be a actual arguments.

If you want to pass something as an option, such as a filename, you can. -fmyfile or -f myfile are both handled in the example.

You can add code to detect a long option by adding “if (!strcmp(p,”longname”)) … just after the char c. But I don’t like long options.

#include <stdio.h>

void process(char *s)
{
    printf("Processing %s\n",s);
}

int main (int cnt, char **a)
{
    int i;
    for (i=1; i<cnt && a[i][0] == '-'; i++)
    {
        char *p = &a[i][1];
        char c;
        if (*p == '-')
        {
            i++;
            break;
        }
        while (c = *p)
            switch (*p++)
            {
            case 'a':
                printf("Option a\n");
                break;
                
            case 'b':
                printf("Option b\n");
                break;

            case 'f':
                if (!*p && i+1 < cnt)
                    printf("Value for f=%s\n", a[++i]);
                else
                {
                    printf("Value for f=%s\n", p);
                    while (*p)
                        p++;
                }
                break;
                
            default:
                printf("Bad switch %c\n",c);

            }
    }
    for (;i<cnt;i++)
        process(a[i]);
}

The above code assumes that options precede arguments. If you want to mix them the following code allows for complete anarchy – but you can end it using the “–” option, which will take any following flags as arguments. As a bonus it shows how to add a long argument.

#include <stdio.h>
#include <string.h>

void process(char *s)
{
    printf("Processing %s\n",s);
}

int main (int cnt, char **a)
{
    int i;
    int moreargs=1;

    for (i=1; i<cnt; i++)
    {
            if (moreargs && a[i][0] == '-')
            {
            char *p = &a[i][1];
            char c;
                if (*p == '-')
                {
                    moreargs = 0;
                    continue;
                }
                if (!strcmp(p,"long"))
                {
                    printf("Long argument\n");
                    i++;
                    continue;
                }

                while (c = *p)
                    switch (*p++)
                    {
                    case 'a':
                        printf("Option a\n");
                        break;

                    case 'b':
                        printf("Option b\n");
                        break;

                    case 'f':
                        if (!*p && i+1 < cnt)
                            printf("Value for f=%s\n", a[++i]);
                        else
                        {
                            printf("Value for f=%s\n", p);
                            while (*p)
                                p++;
                        }
                        break;

                        default:
                            printf("Bad switch %c\n",c);

            }
        }
    else
        process(a[i]);
    }
}



No talk from TalkTalk 2

Hardly a week goes by without someone contacting me about a problem with their email. Pretty much every time they’re just doing something wrong.

“Your message bounced back because you spelled your friends name wrong.”

I’ve learned to say it without sounding judgemental; or I think I have. Everyone’s done it, after all. It’d be nice if people checked before blaming the mail server, but so would world peace and I’m not hopeful I’ll see either.

But last week was a bit different. Someone got a bounce-back after emailing someone@talktalk.net, but the address in the bounce was someone@www.talktalk.co.uk. I know what you’re thinking; same as me. Someone had manage to type their address wrong in their iPad and the replies were to somewhere silly. (Why’s it always Apple users)

Not so this time. After more complaints I checked TalkTalk’s email server. First thing to check is the MX records. Hang on, there aren’t any!

An domain MX record simply tells other mail servers where to send email for that domain. In the absence of an MX record, a mail server is supposed to send email for a domain to it’s IP address (A record). Not everyone knows. this. As a final roll of the dice, it’s allowed to send it to a domain name’s alias (CNAME).

It turns out that talktalk.net lacks an a record, and it’s CNAME is www.talktalk.co.uk. This kinda makes sense – anyone going to the obsolete talktalk.net web site will end up at www.talktalk.co.uk. Great for web users, but it also means that all the email going to talktalk.net customers will be directed to their mail server. Not cool. Unsurprisingly their web server didn’t know what to make of it.

Was this something weird with my DNS? Nope. I tried it multiple DNS servers on several networks, and Google’s 8.8.8.8 service with exactly the same results. Definitely wrong; and it was a Saturday so there was no one at the company to TalkTalk to. I sent an email to the address their tech support suggested, and got a snotty “we’re not talking to you because you’re not a customer” response. Er, no. At this stage it was on behalf on an ISP trying to resolve a serious problem for their customers. How dumb can you get?

Now TalkTalk is an interesting company. It’s basically a mishmash of many ISPs purchased over time by Charles Dunstone’s Carphone Warehouse. These include Opal, Pipex, Nildram, and OneTel, AOL, Virgin’s ADSL business. The group has not been without its problems, including being slammed by the ASA and Ofcom for not delivering what it promised, and let’s not forget the famous 2015 data heist, malware infected home routers, slamming, and customer privacy concerns (Phorm, URL harvesting with Huawei and so on).

However, a big worry is how these disparate ISPs have been on-boarded to the TalkTalk communication bemouth. The answer is probably “badly”, and woe betide anyone on a legacy service such as an @talktalk.net email address. We had the same problem a year or so ago with @onetel.co.uk emails; TalkTalk had kindly left the service running but had no way of known which customers had left and who was using it for free. It was twenty years before they decided to pull the plug on it and see who squealed.

Naturally I phone around about the talktalk.net MX records to see what other were experiencing, and the consensus was that they’d decide to pull the plug on these legacy accounts too.

Of course, having bad/no MX records in your DNS doesn’t cause an overnight meltdown. DNS entries are often cached, and drop off senders’ servers over time. To add to the confusion, many high volume providers trying to save a few quid don’t even bother to check MX records when sending – they simply use the last known good destination server and “do something” when it fails to connect for a period. Freemail users may not have noticed a problem corresponding with their chums on TalkTalk.net – at least not for a while.

So what did I do? The user was convinced they were infected with malware (as they do) so for a quiet life I faked up the last known good talktalk.net zone in a local DNS server and sat back waiting for the actual server to be turned off. But a week later they’d fixed it; so that’s alright then. For now. I guess legacy customers of the worst domestic broadband provider in the UK (consistently, along with Virgin Media and Plusnet and Vodafone, according to Which? Surveys and Ofcom rankings for customer service) aren’t going to heed any warnings about shifting their email service elsewhere before it’s too late.

Graph showing trend data on residential consumer complaints received by Ofcom across fixed broadband by communications provider.   It shows the fixed broadband complaints per 100,000 subscribers for the Q2 2019 – Q1 2021 period.   Virgin Media generated the highest volume of fixed broadband complaints (at 33) in Q1 2021 followed by Vodafone at 24.    EE and Sky generated the lowest volume of fixed broadband complaints with both at 7.


Australia bites back

Well known conspiracy theorist and tennis player Novak Djokovic appears to have gained entry to Australia without the covid-19 vaccination that he and his wife Jelena oppose, even though it’s a requirement for everyone else.

Jelena Djokovic is on record as believing that 5G mobile phones are the real cause of Covid-19.

It appears Djokovic obtained this exception on a technicality – that he’d tested positive for Covid19 in the last six months. Normally exemptions are granted by an independent (and blind) panel to people with documented medical conditions (usually cardiac) that would make vaccination risky. Immunity through past infection makes the matter less urgent. Does Djokovic really have a dicky ticker? You wouldn’t think so to look at him.

Now the Australian Prime Minister, Scott Morrison, has said he could be on the next plane home because of another technicality – his visa was completed incorrectly.

You’ve got to admire the Australian way of doing things. However, I’d be surprised if the wealth of the rich and famous doesn’t prevail. But whilst I have no interest in watching tennis, I must say this is the shaping up to be the best soap opera coming out of the country since neighbours.

Meanwhile, in France, their controversial but entertaining president has made it clear his strategy is to “piss off” the vaccine dodgers, rather than forcing them to be vaccinated by law.

« Moi, je ne suis pas pour emmerder les Français », confie-t-il tout d’abord. Mais « je peste toute la journée contre l’administration quand elle les bloque. Eh bien, là, les non-vaccinés, j’ai très envie de les emmerder. Et donc, on va continuer de le faire, jusqu’au bout. C’est ça, la stratégie ». Source: Le Parisien

To put this in to context, the UK has been playing softly with the anti-vaxxers, but other European countries are gearing up for compulsory vaccination – starting with Austria, with Italy and Germany not far behind.

Has Macron gone mad? Politicians on the left and right have condemned his language, and the admission of his strategy. However, with 90% of France vaccinated, I suspect he’s gambling that the majority have lost patience with the needle-phobic 10% playing Jacques, and he’s basically asking people to side with him or them. Media politicians have been tricked into knee-jerk siding siding with “them”.

How to really add a plugin to WordPress manually

You’d have thought that a google search for “manually add plugin to WordPress” would turn up lots of articles on how to do this, but, er, no. They all seem to tell you to log in to the site and do this or that on the GUI. That’s not doing it manually – it’s using the GUI. If the GUI doesn’t work, then you need to do it manually. Here’s how:

The method is actually simple if you remember it. You download the plugin from the site (e.g. https://wordpress.org/plugins/) and you’ll end up with a DOS/Windows .ZIP file. Unpack this any way you wish and you’ll get a directory with some file in it. As a sanity check, one of these files will have the same name as the directory, but ending in .php.

Take this whole directory and copy it to /wp-content/plugins. That’s the directory – not the files in the directory.

That’s it. You’re done. It’ll appear in the plugins dashboard.

The Huawei thing

A few months ago I was asked for comment on the idea that an embattled Theresa May was about to approve Huawei for the UK’s 5G roll-out, and this was a major security risk. Politics, I assumed. No one who knew anything about the situation would worry, but politicians making mischief could use it to make a fuss.

Now it’s happened again; this time with Boris Johnson as Prime Minister. And the same old myths and half-truths have appeared. So is Chinese company Huawei risky? Yes! And so is everything else.

Huawei was founded by a brilliant entrepreneurial engineer, Ren Zhengfei in 1987, to make a better telephone exchange. It came from the back to become the market leader in 2012. It also made telephones, beating Apple by 2018. While the American tech companies of the 1980’s grew old and fat, Huawei kept up the momentum. Now, in 2020, it makes the best 5G mobile telephone equipment. If you want to build a 5G network, you go to Huawei.

Have the American tech companies taken this dynamic interloper lying down? No. But rather than reigniting their innovative zeal, they’re using marketing and politics. Fear, Uncertainty and Doubt.

Some arguments:

“Huawei is a branch of the evil Chinese State and we should have nothing to do with it.”

Huawei says it isn’t, and there’s no evidence to the contrary. The Chinese State supports Chinese companies, but that’s hardly novel. And whether the Chinese State is evil is a subjective judgement. I’m not a fan of communist regimes, but this is beside the point if you’re making an argument about technology.

“Huawei is Chinese, and we don’t like the government or what it does”.

So we should boycott American companies because we don’t like Trump? We do business with all sorts of regimes more odious that the CPC, so this is a non-argument. You could make a separate argument that we should cease trade with any country that isn’t a liberal democracy, but this could be difficult as we’re buying gas from Russia and oil from the Middle East.

“Huawei works for the Chinese secret service and will use the software in its equipment to spy on, or sabotage us.”

First off, Ren Zhengfei has made it very clear that he doesn’t. However, there have been suspicions. In order to allay them, Huawei got together with the UK authorities and set up the HCSEC in Banbury. Huawei actually gives HCSEC the source code to its products, so GCHQ can see for itself; look for backdoors and vulnerabilities. And they’ve found nothing untoward to date. Well, they’ve found some embarrassingly bad code but that’s hardly uncommon.

Giving us access to source code is almost unprecedented. No other major tech companies would hand over their intellectual property to anyone; we certainly have no idea what’s inside Cisco routers or Apple iPhones. But we do know what’s inside Huawei kit.

“Because Huawei manufactures its stuff in China, the Chinese government could insert spying stuff in it.”

Seriously? Cisco, Apple, Dell, Lenovo and almost everyone else manufacturers its kit in China. If the Chinese government could/would knobble anything it’s not just Huawei. This is a really silly argument.

Conclusion

So should we believe what the American’s say about Huawei? The NSA says a lot, but has offered no evidence whatsoever. The US doesn’t use Huawei anyway, so has no experience of it. In the UK, we do – extensively – and we have our spooks tearing the stuff apart looking for anything dodgy. If we believe our intelligence services, we should believe them when they say
Huawei is clean.

Being cynical, one might consider the possibility, however remote, that America is scared its technology companies are being bested by one Chinese competitor and will say and do anything to protect their domestic producers; even though they don’t have any for 5G. Or if you really like deep dark conspiracies, perhaps the NSA has a backdoor into American Cisco kit and wants to keep its advantage?

The US President’s animosity to trade with China is hardly a secret. Parsimony suggests the rest is fluff.

Amazon Echo vulnerable in Smart Speaker battle

When Google launched its smart speaker it was playing catch-up with Amazon. The Echo had an established ecosystem, and unless Amazon blew it, this lead looked unassailable. The field was Amazon’s to lose.

Since then, Amazon’s arrogance seems to have taken it towards such a losing strategy. Glitzy launches of new gadgets are not enough to maintain a lead. I have a sample of pretty much every Echo device ever sold, and the newer ones aren’t that much better than the old ones. The build quality was always good, and they work.

What could damage the Echo is the slide in functionality.

Most people assumed that the rough edges – things you should be able to do but couldn’t – would be addressed in time. Google stole a march by recognising the person speaking, but Amazon has caught up. Sort-of. Meanwhile Google has been catching up with Amazon on other functionality and ecosystem.

What Amazon is failing to realise is that they’re selling smart speakers. This is the core functionality. They came up with the technology to link speakers in groups, so you could ask for something to be played “Upstairs”.

This is still there, but it’s been made almost useless. In the beginning you could play anything you wanted on an Echo. All music purchased direct from Amazon was added to your on-line library. There was also Amazon’s Prime music service. The latter has gone down hill recently, with the good stuff moved to a separate “full” streamin service. The ability to play your own music by uploading your MP3 files to your library. This facility has just “gone”, as of the start of the year.

Loyal Amazon customer assumed that it would go the other way, and that you’d be able to stream from your local source to your smart speaker groups. Amazon has blocked this, although some third party skills can play media to a single Amazon speaker. Not so smart.

Now Echo users are about to be hit again. From next month feed of BBC Radio, and other things, is changing. You’ll still be able to get them, but only on a BBC skill. The effect of this is that you can’t use an Echo as a radio alarm clock and more, the alarms will be confined to built in sounds. No longer will I be able to wake up to Radio 4’s Today program at 6am. Unfortunately I will still have to wake up at that time.

Echo Dot with Time Display – but now no use as a radio alarm

Ironically, one of Amazon’s enhancements is an Echo Dot with a time display. Just in time for it to be made useless by the software.

Looking at the change, I also strongly suspect you won’t be able to play a radio station on a group of speakers either. The speaker group technology is limited to Amazon’s own streaming service.

The Echo/Alexa system used to just work. Unless Amazon reverses these catastrophic decisions, it just doesn’t work. And now the public has a taste for this functionally, someone else can walk in and provide it.

The Religion behind Climate Change

Global Warming is real. The high priests of the peoples’ religion have proved it to the satisfaction of all true believers. Or do I mean science has proved it to all right-thinking people?

Famously, Donald Trump thinks it’s all a conspiracy. He also thought (thinks?) that Obama was a foreign import jihadist and the American Democratic Party is run by commuinists. So if Donald Trump thinks Climate Change is a trick, logic dictates that it must therefore be real, right?

I think it’s time we looked at some facts:

The world’s climate has been getting warmer. For a long time. Between the 15th and 18th Century the River Thames froze over in London. In the early 1800’s it stopped, and hasn’t done so since. Therefore things must be getting warmer. Of this there is no doubt.

Is our industrial activity the reason? Well no. We didn’t start to industrialise and burn fossil fuels until well in to the 19th Century.

So it’s pretty clear that the planet has been warming up for a long time prior to major human industrial activity. We couldn’t have started it, because it began before we burnt fossil fuels to any scale.

But… is burning fossil fuels accelerating this natural change in our climate? Well that’s another question. 97% of Climate Change scientists say it is, so it must be true. I mean: who’s going to argue with one scientist, never mind the vast majority? Scientists are honourable people, not interested in worldly matters, and have no reason to lie to us about stuff we don’t understand.

Yeah, right!

Scientists are no more or less honourable than anyone else; they do care about money and there are all sorts of reasons not to believe them. This is strikingly similar to the high priests of the old religions, don’t you think? And when you look at it, the same driving forces appear to be shaping their behaviour.

For a long time the sun went around the earth. The priests said so. Anyone with deviant views was shouted down as an idiot, and if they persisted they could eventually be burnt at the stake as an example to others. No one who argues with priests or scientists is going to be taken seriously. OR ELSE!

Did the priests have any proof that their view of the cosmos was correct? They had irrefutable evidence. Ask any priest and they’d tell you – everyone knew it was true so it must be. Who was going to appear foolish (or be put to death) by disagreeing with the consensus? But in reality the priest had other reasons to believe they were correct: their careers and livelihood depended on them sticking to the story. If you were a priest you had a good job for life. People would respect you, give you money, a nice house and plenty of food, and not expect you to get involved in nasty worldly stuff. Becoming a priest has always been a good career choice. The only career-limiting thing you could do would be to question the “truth”. If anyone did, other people would too, and eventually the religion would lose control. And if a priest did it, even more so. Errant priests would never do.

Is the modern-day scientist really any different? It’s always a good idea to follow the money. They have a job in research and their salary is paid for by someone. To get on in the world they need to publish papers, so they can’t remain silent. When they’re working for a university department set up to study climate change, its not politic to say that the subject is over-blown and the world would be better off studying something else. They’re going to say it’s important, and probably real (but that funding is needed for further research). So the the majority of scientists who are paid to believe in climate change that express an opinion are unlikely to express one that’s going to see them out of a job; and then torn apart by their colleagues for breaking the faith.

Ask a scientist not involved in climate change research whether global warming is caused by human activity, and they won’t have a strong opinion because it’s not their field. Or they’ll close ranks with the rest of the “priesthood”, or “scientific community”.

Likewise, I don’t know if human activity is accelerating climate change. I suspect it may well be, but I can’t discount the fact that most academic researchers of the subject also say their pay-cheque is justified. Always follow the money.

Then there are the environmentalists, myself included. I don’t bang on about human-caused climate change. I don’t know how much we are to blame. I don’t know if we can slow or reverse it. But I do know that using irreplaceable resources as though the supply is infinite is a stupid idea. I do know that polluting the environment and destroying the natural world is a bad thing. So when a government, with the backing of its high priests of science, says it wants to reduce pollution and fossil fuel consumption I’m hardly likely to disagree, whatever the government’s real motive. (I suspect the real motive is tax revenue).

So what is it with society and its deference to scientists? In the past, if you were ill, you went to the priest for help. Not just the church infirmary; you did whatever the priest told you to in order to be cured. At the very least, you had nothing much to lose by trying. In the modern world we go and see a medical scientist (doctor), as we believe their results are better than the priests. Doctors can’t cure everything, in fact you could argue they can cure comparatively little. Many ailments cure themselves and the priest or doctor gets the credit anyway. But doctors do have demonstrably better outcomes than the priests they’ve displaced. If you’re ill, anyone you believe can cure you is going to be your best friend.

And then there are the politicians. Since the beginning of time the priests have been used by rulers to persuade the populous to go along with some policy or other. Do you want to plunder the tribe up the valley? Get your holy man to call it a religious duty and the plebs will do anything you ask of them, however foolish. Even if they’re not scared of you, they are of the priest. More precisely, they’re scared of the power that only the priest understands and can control. So the tribal chief is happy. The priest is happy because the chief keeps him in the easy life, and the plebs are happy because they’re doing the right thing for them and their mates without having to think for themselves. Or they’re dead on the battlefield, but living it up in the afterlife.

Now, if you’re a politician and announce you want to hike taxes it’s unlikely to have a positive effect on your chances of re-election. Unless you can persuade the people it’s a really good idea for some reason or other. The problem is that they won’t listen to you, because you’re a politician. If you can get the high priest (or scientists) to tell them that raising taxes is virtuous, and the wrath of something will descend on them otherwise, then you can still raise the taxes you need and avoid the blame when people have less money in their pockets and you have more to spend.

I’m not saying that using taxation to reduce pollution, or finite resource consumption, is a bad thing. Anything that does that is good. But I can’t help having a nagging feeling that the motivations of governments have more to do with the revenue, as government policies usually contradict these supposed ideals unless they can make money out of it.

The switch to sustainable transport is a good example – jobs and taxes are created by cars, so building more roads is a good thing as far as they’re concerned. And they can even boost economic activity by changing the rules to encourage people to buy newly produced cars. This is contradicts the idea that they want to reduce consumption, emissions and pollution. When Trump says he wants to put industry before environment he’s just being honest.

When it comes to whether pumping carbon dioxide and methane into the atmosphere is a good idea, it clearly isn’t. Atmospheric carbon dioxide levels have increased rapidly in the 20th century and it can only make the planet heat up. Victorian scientists raised the red flag at the boom in burning coal, and all the evidence suggests they were correct. What’s a stretch is the idea that by reducing carbon dioxide we can stop or reverse a trend that started a long time before we started; we need to accept the earth has been warming up since records began and plan accordingly. And please stop burning fossil fuels as this would be A Good Thing in itself.

My first draft of this diatribe ended about here, but in the summer the president of the Royal Statistical Society gave a very interesting address at their annual jamboree, which deserves a much wider audience as it drew together threads concerning why people are becoming disenchanted by experts, especially where statistics are concerned.