Arjun Prasad
Arjun Prasad

Reputation: 43

How can I pass executable command as argument to adb shell?

I am getting error while executing the below command:

$ sudo adb shell ping `cat /data/my_address.pst`

Where my_adress.pst file contains the ip address.

But the same command works fine when executed from the shell.

$ sudo adb shell

$ ping `cat /data/my_address.pst`

How can i pass executable commands like this? please throw some light on this.

Thanks.

Upvotes: 1

Views: 1791

Answers (2)

Alex P.
Alex P.

Reputation: 31676

Your cat /data/my_address.pst command gets executed by local shell so you need to escape the backticks or single quote the whole command. Also you do not need sudo and use of $() is preferable over backticks:

adb shell 'ping $(cat /data/my_address.pst)'

Upvotes: 1

m0skit0
m0skit0

Reputation: 25873

Escape the ` so it is not interpreted by the shell.

adb shell ping \`cat /data/my_address.pst\`

Upvotes: 1

Related Questions