Python subprocess call with% s and * in the adb shell


I am learning python and i am loving it how it can help me automate some of my daily routines. I am using google for all my questions and till now I have been very successful. But this time i am really stuck and have already spent 2 days on this.

The below code does not work as there is %s and * in same line

from Tkinter import *
import subprocess as sp
regLists = ['1b7', '1b6', '209', '197']
valLists = ['23', '80', 'ab', '73']
for regs,vals in zip(regLists,valLists):'adb shell "echo %s %s > /d/asoc/*-snd-card*/*_code*/code_reg"'%(regs,vals), shell=True)


Error: /system/bin/sh: can't create /d/asoc/*-snd-card*/*_code*/code_reg:
No such file or directory

  • a) the path name is different for each device
  • b) * is used to find the path name inside linux directory

Working Code is shown below as there is no * and the entire path is mentioned'adb shell "echo %s %s > /d/asoc/xyz-snd-card-device45/ffde_code-fffb/code_reg"'%(regs,vals), shell=True)

Please can someone help how i can change the above code so that i can use above code...

for regs,vals in zip(regLists,valLists):
    echo = "echo {} {} > /d/asoc/*-snd-card*/*_code*/code_reg".format(regs,vals)
    sp.check_call(["adb", "shell" , echo])