Friday, 30 August 2019

cat: -: No such file or directory

A weird error that took me a while to track down. I came across it in the iproute2 configure script which was setting the TMPDIR environment variable before using a cat heredoc statement (e.g. when you include some data in a shell script which demarked using markers - in this case 'EOF'):
TMPDIR=$(mktemp -d config.XXXXXX)
cat >test.c <<EOF
stuff and more stuff
The problem is that the TMPDIR variable is used by the cat command. And in this case the TMPDIR is set to the output of mktemp which creates a temporary directory in the current working directory, but this is not usable by the cat command and results in the above error - it seems that cat command will only accept a TMPDIR if it is in /tmp and fails if it is set to another base directory?! According the man page mktemp is supposed to default to using /tmp but it's not working on Linux - It works fine on MacOS. Anyway so one just need to make the following change:
TMPDIR=$(mktemp -d /tmp/config.XXXXXX)

Monday, 26 March 2018

Fix: Text message (SMS) Not Delivered

So your iPhone/Phone is unable send text messages - It show a red exclamation mark (!) and says Not Delivered - you've tried to send an SMS (Green coloured message boxes) to a few people over a few days and it's still not working. You've tried Settings->General->Reset->Reset Networking Settings Settings->General->Reset->Reset All Settings, restarting your iPhone, pulling the SIM in/out and read Apple's help page  - all to no avail.

Then the problem may be down to an issue with the Short Message Service Centre (SMSC) setting on your phone - which is used when sending SMS messages. It can be checked/modified from the normal Phone app - type in the the following codes into the keypad and hitting the call button to see what the current SMSC setting is:
You should then see a grey box fill the screen with a message:

Setting Interrogation Succeeded
Service Centre Address

Immediately below this text you'll see the number that your phone is using as your SMSC. You can search the Internet for your operator's SMSC and if it doesn't match the one you see above then you can set it to the correct one using the following general code - you'll need replace in the SMSCNUMBER with your operator's SMSC (to the get the plus(+) symbol you need to hold your finger down on the zero key):

 e.g.: For Talk Talk UK:
 e.g.: For Vodafone UK:
e.g.: For O2 Prepay UK:

After you hit the call button it will bring up another grey box saying:

Setting succeeded
Service Centre Address
No Address

This means it's done and SMS/texting should work now - Try it and see!  (If not then revisit my suggestions in the first paragraph).

For other phones (e.g. Android) the above should work, but you can also apparently bring up a special Phone information screen where you can check and modify your SMSC by typing this code on the Phone keypad:

The SMSC is usually stored in the SIM card on your phone - for SIM card reader folk (see my other article on SIM readers): it's at EF SMSP (short message service parameters), the full path to the file is 7F10 / 6F42 or using AT commands: AT+CSCA?

As to why the SMSC might have changed - feel free to comment on that!

Monday, 3 July 2017

Websites (e.g. TfL) not working in Firefox

Have you been trying use websites, like Transport for London (TfL) journey planner, in Firefox recently (or for a while) and found that they seem broken - e.g. TfL only shows the bus route?! Well you're not the only one. Since Firefox version 42 Mozilla has enabled Tracking Protection which is generally a very good thing (as there's way too many trackers out there keeping tabs on where/when/what you're up to). Sadly some sites aren't designed to cope with that so they fail to work properly - like TfL and others.

Fortunately it's easy to fix once you know how: When Firefox blocks tracking elements it helpfully puts an additional 'shield' icon in the URL bar to indicate the fact. If you click on the shield icon it shows a button to 'Disable protection for this site' - which disables tracker blocking for that site - you'll then see a line drawn through the shield to indicate this.

One other thing is that if you also use other blocker plugins/extensions in Firefox (e.g. uBlock, Ghostery, AdBlockPlus) you may also need exempt the site in those too.

Thursday, 10 November 2016

Delete pending Calander invites - without notifying sender

So we all get these calendar (iCal) invites which the MacOS/OSX Calendar app then notifies us about in its badge icon and on the '+' button in the app. But what if you don't want to accept or reply to these invites - annoyingly enough there is no way to just delete them without sending some form of notification.

So how to go about getting rid of them? Well there's actually a way to do it - You create a new Calender (File->New Calendar->iCloud) and just leave the default 'untitled' name, then you find those pesky invites and right click on them and assign them to this new 'untitled' calendar. Then you right click on the untitled calendar and select delete - it then finally asks you if you want to delete without notifications! Gone. Done.

Tuesday, 7 June 2016

Regenerate missing modules.dep.bin

If you're seeing a problem with a missing modules.dep.bin or modules.dep file(s) on your Linux/Ubuntu/Arch box (e.g. libkmod: ERROR ../libkmod/libkmod.c:XXX kmod_search_moddep: could not open moddep file '/lib/modules/kernel_release/modules.dep.bin'), then it may be rebuilt using the depmod command:
sudo depmod

Monday, 2 May 2016

Fix Handbrake crash on OSX(10.11) El Capitan

I just tried to use Handbrake (version 0.99) to rip a DVD on OS X 10.11.4 and it crashed halfways through so I ran Handbrake's update (0.10.5) but it still crashed ;( It turns out that OSX El Capitan has removed a software library that is used to decrypt DVDs (libdvdcss) from the system - so if you've got an older dodgier version (of libdvdcss) lying around it works but crashes. Either that or Handbrake fails to find anything on the DVD you're trying to rip, as mentioned on Reddit.

To fix the problem you need to install an up to date version of libdvdcss - either by downloading a slightly old version and copying it into the /usr/loca/lib e.g. if the downloaded library file is in Downloads:
sudo cp ~/Downloads/libdvdcss.2.dylib /usr/local/lib
Or you can build/install the latest version using Macports, homebrew, or from source. If you use Macports then you may need to link the macports installed version to /usr/local/lib (so that Handbrake can find it):
sudo ln -s /opt/local/lib/libdvdcss.2.dylib /usr/local/lib
Now start Handbrake and you should be good to go...

Friday, 29 April 2016

Using cheap SIM card readers

I ordered one of those cheap SIM (Smart card) card readers (often in blue plastic) that take a while to arrive from China. When it showed up I plugged it into my on Linux box and it was recognised as:
$ lsusb
Bus 001 Device 017: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
And it had created a serial device: /dev/ttyUSB0. So how do you actually use the thing? It ships with a dodgy mini-CD full of some apparently even dodgier Windows software - not much use. If you try to connect to the serial port using minicom etc you don't get much.

However it is possible to use it on Linux (Whilst OSX has shipped with the relevant deamon pcscd for a while, it seems that openct is not fully supported so it may not work with this little blue one - unless someone ports it). There are two ways to use it - the simplest way is to use apps that can talk directly to the serial port and communicate with the device such as pysimreader or pysim.

The second more advanced way requires some setup on Linux - so you'll need to install a few packages:
$ sudo apt-get install pcscd openct pcsc-tools
Then to get the SIM reader going you need to add the following to the openct config file (/etc/openct.conf) - so it knows where to find the SIM reader (it's known as a "phoenix" style reader):
reader phoenix {
    driver = phoenix;
    device = serial:/dev/ttyUSB0;
And uncomment the following lines in openct config file for pcscd (/etc/reader.conf.d/openct) - so that it recognises openct devices:
DEVICENAME       /dev/null
LIBPATH          /usr/lib/
CHANNELID        0
Then you make sure the SIM reader is plugged in and restart the daemons:
$ sudo /etc/init.d/openct restart
sudo /etc/init.d/pcscd restart
Then you should be good to go. You can check the device has been recognised by using the pcsc_scan utility - and you should see it find the OpenCT Reader as below:
$ pcsc_scan 
PC/SC device scanner
V 1.4.22 (c) 2001-2011, Ludovic Rousseau <>
Compiled with PC/SC lite version: 1.8.10
Using reader plug'n play mechanism
Scanning present readers...
0: OpenCT 00 00

Fri Apr 29 16:25:33 2016
Reader 0: OpenCT 00 00
  Card state: Card inserted, Shared Mode, 
  ATR: .....

Then you can try out apps like cardpeek and others - install it using apt-get:
$ sudo apt-get install cardpeek

One can use it to read any compatible smart card chip using the reader. If you want to try reading a credit card you'll need to chop out the smart card section to make it into a SIM shape so it can fit into the unit. There's a bunch of more esoteric apps/libs on Github for this stuff like card, simLAB, etc. It is also possible to use the device to authenticate to EAP-SIM/AKA WiFi (thanks to this guy for his blog post that helped me on some of the above).

Note: If you find that the apps aren't working properly (check the logs for weird behaviour - enable logging - in openct edit /etc/openct.conf and add/modify debug = 9, for pcscd start it manually: sudo pcscd -a -d and then you'll have them both log to syslog) you may have a buggy version of openct (I had a problem with openct 0.6.20-1.2ubuntu1) so you'll need to get the latest version from the openct site and install that instead. Note that you'll probably need to build it from source e.g:
$ git clone
cd openct
./configure --enable-pcsc
sudo make install
Then you'll need to edit the openct config file for pcscd (/etc/reader.conf.d/openct) - so that it uses the newly installed version of openct in /usr/local:
 LIBPATH          /usr/local/lib/
Then restart things:
$ sudo /etc/init.d/openct stop
sudo /usr/local/sbin/openct-control init 
sudo /etc/init.d/pcscd restart
Now you should be on track again.
[Updated: 5may16: Adding simple serial apps]

Wednesday, 24 February 2016

Headphone jack stopped working on your iPad?

The headphone jack on my iPad just stopped working - i.e. when I plugged in my headphones sound still came out of the built-in speakers and I heard nothing in my headphones (the plug was fully inserted). Darn it the jack must have finally broken...?! But then again it could just be a software issue (iOS9.2.1) - so I powered off my iPad and then switched it on again. Low and behold the headphone jack was back to normal! (This fix may also work for iPhones...).