[英]"/system/bin/sh: syntax error: '(' unexpected" when specifying a file in ADB
I have been messing around with adb lately, mostly the push command.我最近一直在弄乱 adb,主要是 push 命令。 it is a life saver when the phone doesn't want to mount like a flash drive.当手机不想像 flash 驱动器那样安装时,它可以挽救生命。 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:尝试了它,它在/storage/emulated/legacy/Downloads/
中名为“Wolves.mp3”的文件上完美运行,但是当我尝试名为Coyote (group).mp3
的文件时,它给出了错误消息:
/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.我尝试了许多不同的解决方案,例如从file:///storage/...
更改为仅/storage/...
, escaping symbols according to this site ,这只会让我更加困惑。 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.我什至尝试使用常见的 \ 来转义符号/storage/emulated/legacy/Downloads/Coyote\ \(group\).mp3
但即使那样也会出现完全相同的错误。
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
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!知道 file:// 协议用于超链接结构,我记得你通常的 url 会用字符串%20
替换空格符号,所以我将这首歌推送到我的另一部手机,并用 %20 替换空格,然后关闭它去了,现在我只需要用它们的超链接等价物替换所有特殊符号,例如 ()[]{}-+!@#$%^&*,这应该可以解决我所有的问题!
[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.在我的音乐中,我能找到的唯一一首没有任何特殊符号的歌曲是 Ra Ra RasPutin。 it works though!它虽然有效!
Working solution:工作解决方案:
adb shell am start -a android.intent.action.VIEW -d file:///storage/emulated/legacy/Downloads/coyote \(group\).mp3 -t audio/mp3
Explanation: Here adb is used from android shell and shell has special meaning for ()round brackets and thus above error occurs.解释:这里adb使用的是android shell shell 对()圆括号有特殊意义,所以出现上述错误。 Thereby escaping brackets will solve it.从而 escaping 括号将解决它。
echo "file:///storage/emulated/legacy/Downloads/coyote (group).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3
But here echo "file:///storage/emulated/legacy/Downloads/coyote \(group\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3 Error: /system/bin/sh: Unexpected '('
但这里echo "file:///storage/emulated/legacy/Downloads/coyote \(group\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3 Error: /system/bin/sh: Unexpected '('
echo "file:///storage/emulated/legacy/Downloads/coyote \(group\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3 Error: /system/bin/sh: Unexpected '('
will not work. echo "file:///storage/emulated/legacy/Downloads/coyote \(group\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3 Error: /system/bin/sh: Unexpected '('
将不起作用。
Because one time round bracket is escaped with backslash and that solves the android shell problem but the backslash act as special charater for xargs computer shell and hence it also needs to be escaped.因为有一次圆括号用反斜杠转义,解决了 android shell 问题,但反斜杠作为 xargs 计算机 shell 的特殊字符,因此也需要转义。 So Solution will be: echo "file:///storage/emulated/legacy/Downloads/coyote \\(group\\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3
所以解决方案将是: echo "file:///storage/emulated/legacy/Downloads/coyote \\(group\\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3
echo "file:///storage/emulated/legacy/Downloads/coyote \\(group\\).mp3" | xargs -n1 -I {} adb shell am start -a android.intent.action.VIEW -d "{}" -t audio/mp3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.