1# FAQ
2
3## Is it possible to use cli tool for automated file management?
4
5Yes. There's two options of achieving this.
61. Pass every command as **single** command line argument, e.g. ```aft-mtp-cli "get Pictures" "cd Pictures" "ls"```. If you need quoted argument for commands, you have to escape them, e.g. ```aft-mtp-cli "get \"Pictures\""```.
72. Pass -b command line option and feed your script to stdin.
8
9## How to unmount my device?
10
11Run
12```fusermount -u <path>```
13
14
15## I'm getting «ioctl(_fd, USBDEVFS_CLAIMINTERFACE, &interfaceNumber): Device or resource busy» or «Device is already used by another process» exception/message box right after you started the application. This clearly indicates that some other process is accessing MTP device right now.
16You could do the following steps to find the offending process:
17* Open you console emulator (gnome-terminal, konsole, whatever) and type: ```lsusb``` (sudo apt-get install usbutils if it did not start) and find your device in its output, for example
18```
19Bus 006 Device 070: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)
20```
21* Start fuser ```sudo fuser /dev/bus/usb/<BUS>/<DEVICE>``` (sudo apt-get install psmisc if it did not start)
22* It should output something like this: ```/dev/bus/usb/006/070: 23253 24377``` (actually, there could be more of them after semicolon, like : 24377, 24378, …) so, 23253 and 24377 are the pids of the processes which opened your device.
23* So, finally run:
24```
25ps -x -q 23253
2623253 ?        Sl     0:00 /usr/local/bin/android-file-transfer
27ps -x -q 24377
2824377 ?        Sl    21:14 adb -P 5037 fork-server server
29```
30Usually, adb is not offending process, because it uses another interface, so the /usr/local/bin/android-file-transfer is the one
31
32## No MTP device found, but it's listed in lsusb
33
34Maybe you don't have sufficient privileges to access usb device under /dev/bus/usb
35
36First, try checking what bus and device numbers your device has by running lsusb command and finding your device in its output.
37
38For instance, my old Nexus 5 phone:
39```
40Bus 010 Device 003: ID 18d1:4ee2 Google Inc. Nexus Device (debug)
41```
42
43Note the bus/device number in row with your device Then, go /dev/bus/usb/<bus> and check file <device> there. (010 and 003 respectively in my case).
44```
45ls -l /dev/bus/usb/010/
46crw-rw-r--  1 root usb     189, 1152 Jan  5 21:30 001
47crw-rw----+ 1 root plugdev 189, 1154 Jan  5 22:46 003
48```
49
50plugdev group may have different name for different distros, consult your distro's manual for details. You can check what groups you're in by running 'id' command.
51
52If device's group is 'root', then you have to add udev rule:
53http://reactivated.net/writing_udev_rules.html
54Please find some examples there.
55