Search code examples
androidadb

"/system/bin/sh: syntax error: '(' unexpected" when specifying a file in ADB


I have been messing around with adb lately, mostly the push command. it is a life saver when the phone doesn't want to mount like a flash drive. lately I have been loading audio files onto the phone and discovered a neat one-liner that can make the phone PLAY the audio from the lock screen. tried it and it worked flawlessly on a file called "Wolves.mp3" in /storage/emulated/legacy/Downloads/, but when I tried a file called Coyote (group).mp3 it gives the error saying:

/system/bin/sh: syntax error: '(' unexpected

I tried many different solutions, such as changing from file:///storage/... to just /storage/..., escaping symbols according to this site, which only drove me to further confusion. I even tried using the common \ to escape the symbols /storage/emulated/legacy/Downloads/Coyote\ \(group\).mp3 but even that gave the exact same error.

edit

the command I have been running looks like this:

[jaz@Jaz-Jackson ~]$ adb shell am start -a android.intent.action.VIEW -d file:///storage/emulated/legacy/Downloads/coyote (group).mp3 -t audio/mp3

Solution

  • Hey I figured it out!!!

    knowing the file:// protocol is for hyperlink structures, I remembered that your usual urls would replace the space symbol with the string %20, so I pushed this song to my other phone, and replaced the spaces with %20, and off it went! now I just have to replace ALL special symbols such as ()[]{}-+!@#$%^&* with their hyperlink equivalents, and that should resolve all my issues!

    [jaz@Jaz-Jackson]$ adb shell am start -a android.intent.action.VIEW -d "file:///storage/self/primary/Music/Ra%20Ra%20RasPutin.mp3" -t audio/mp3
    Starting: Intent { act=android.intent.action.VIEW dat=file:///storage/self/primary/Music/Ra Ra RasPutin.mp3 typ=audio/mp3 }
    
    

    yes. the only song i could find in my music that didn't have any special symbols was Ra Ra RasPutin. it works though!