SCardEstablishContext: Service not available
I installed the following packages:
- libusb-dev
- libusb++-0.1-4c2
- libccid
- pcscd
- libpcsclite1
- libpcsclite-dev
- List item
- libpcsc-perl
- pcsc-tools
But when I send the pcsc_scan command I received the below output :
root@bt:/# pcsc_scan
PC/SC device scanner
V 1.4.16 (c) 2001-2009, Ludovic Rousseau <[email protected]>
Compiled with PC/SC lite version: 1.5.3
SCardEstablishContext: Service not available.
root@bt:/#
Why?
Note: I use BackTrack5
Solution 1:
It look like your pcscd is not running (service pcscd start).
Solution 2:
Quick strace pcsc_scan
reveals that it tries to open a non-existing file /var/run/pcscd/pcscd.comm
:
stat("/var/run/pcscd/pcscd.comm", 0x7fff315e9dc0) = -1 ENOENT (No such file or directory)
....
SCardEstablishContext: Service not available.
...
exit_group(-1) = ?
+++ exited with 255 +++
And indeed it does not exist:
$ ls /var/run/pcscd/pcscd.comm
ls: cannot access '/var/run/pcscd/pcscd.comm': No such file or directory
This is because there are two parts of pcscd: pcscd.service
and pcscd.socket
, where the latter is responsible for that missing file. Therefore, the proper solution will be:
sudo systemctl restart pcscd.socket
Demo:
$ ls /var/run/pcscd/pcscd.comm
ls: cannot access '/var/run/pcscd/pcscd.comm': No such file or directory
$ sudo systemctl restart pcscd.socket
$ ls /var/run/pcscd/pcscd.comm
/var/run/pcscd/pcscd.comm
Now you can properly enjoy your pcsc_scan
.