user1974708
user1974708

Reputation: 67

Using subprocess to execute ADB command

I am sending an SMS using adb. The following command ./adb shell am start -a android.intent.action.SENDTO -d sms:12345 --es sms_body "the body" --ez exit_on_sent true , while typed in and executed in bash, does it's job but my python script seems to call ./adb only:

    ADB = './adb'
    def callSMScmd(msg, num):
        adbArgs = ('shell am start -a '
                +'android.intent.action.SENDTO -d sms:'+str(num)+' --es'
                +'sms_body "'+msg+'" --ez exit_on_sent true')
        call([ADB, adbArgs])

The proper return would be Starting: Intent { act=android.intent.action.SENDTO dat=sms:12345 (has extras) } Unfortunately this script lists the adb version and all available options; no warnings, no errors. Thanks in advance for any help

Upvotes: 1

Views: 2121

Answers (1)

Alex P.
Alex P.

Reputation: 31686

Make shell a separate parameter:

call(['adb', 'shell', 'am start -a android.intent.action.SENDTO ...'])

Upvotes: 2

Related Questions