0

I want to enter a simple adb shell command, so I navigated to ...\sdk\platform-tools\adb.exe, and opened it. However, I am unable to type in it!

enter image description here

I am a new Mac user after recently moving from Windows, and am unsure why I can't type in the adb. What's wrong?

2

Firstly, Macs run binaries and not .exe files.

This adb is a binary, and must take options.

Open Terminal, from /Applications/Utilities/Terminal.app and you should see something like this (colors should be different): You should see something like this.

Now, type in adb and press return. You should see the same output as you saw in your screenshot. Now, to run the command (the highlighted text in the background), copy (+C) and paste (+V) that text into the terminal window. Everything that follows adb are called "arguments", like modifiers that affect what the command does. This is quite common in shell commands.

   adb shell pm clear com.android.vending
  |-V-||---------------V-----------------|
 Command            Arguments

Alternatively, if you have a binary in a specific location, do: (./ executes a binary)

cd /path/to/the/binary
./binary-name (arguments)

Side note: autocompletion can be very helpful in long directory names: by typing in a fragment of a name, then hitting Tab, autocompletion will fill in the rest of the fragment (assuming there are no similarly named items). Pressing Tab twice will show you what autocompletion can fill in.

$ cd /Users/Ha *presses tab*
$ cd /Users/Harry/

OR

$ cd /Users/H *presses tab twice*
Harry/ Henry/ Hagrid/
$ cd /Users/H
  • Hey, I really loved your descriptive answer. I navigated to my platform-tools directory, which contains my adb.exe, and tried to type in adb and adb shell. However, I got: command not found. What should I do? Here is a screenshot: – Ruchir Baronia Mar 30 '16 at 23:12
  • imgur.com/HkvFg4g – Ruchir Baronia Mar 30 '16 at 23:15
  • To run a binary, it is simply the name of the executable prepended by a ./. In your case, that would be: ./adb shell. Also, it is important to note that the executable inside that folder is not a .exe file, but rather a binary. – perhapsmaybeharry Mar 30 '16 at 23:16
  • To attend to your "command not found" problem, that is due to the binary not being inside your $PATH directory, the paths that your computer looks in for binaries. Try echo $PATH in the Terminal, where you should see multiple paths. These paths are where commands should be placed to be called by just their name. Try moving your adb binary into /usr/local/bin and just calling adb from the main command line. – perhapsmaybeharry Mar 30 '16 at 23:21
  • I am unable to paste into bin: imgur.com/IRoPBO9 – Ruchir Baronia Mar 30 '16 at 23:37
4

By clicking on a unix executable, you run it with the exit argument. If you scroll up to the top you will see something like this:

.../Development/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb ; exit;

The way to run a shell tool is to open terminal (hit command+space and type Terminal then enter) then something like:

cd /wherever/you/have installed/your sdk/platform-tools/
./adb shell

tip: start typing the directory name then hit tab for completion

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .