[Android-development] Complicated adb command help

Jason H jhihn at gmx.com
Tue Oct 1 02:15:42 CEST 2019


I'm trying to get the IMEI from ADB:
abd shell 'service call iphonesubinfo 1 | grep -o "[0-9a-f]\{8\} " | tail -n+3| while read a; do echo -n "\u${a:4:4}\u${a:0:4}"; done ;echo'
This works at the command line, (save any typos), but I cannot get it to work with QProcess. I've tried it as new QProcess()->start(command) as well as ->setProgram(adb); ->setArguments(QStringList {
 "shell", "-x", "'service call iphonesubinfo 1 | grep -o \"[0-9a-f]\\{8\\} \" | tail -n+3| while read a; do echo -n \"\\u${a:4:4}\\u${a:0:4}\"; done ;echo'"
});

and several other permutations. Does anyone know what is going on?
The closest I got was:
/system/bin/sh: service call iphonesubinfo 1 | grep -o "[0-9a-f]\{8\} " | tail -n+3| while read a; do echo -n "\u${a:4:4}\u${a:0:4}"; done ;echo: not found

I've gotten other various not founds, like for grep. Can't seem to get the \ or " ' right. I got it to print the right command on the line as an error, executing it in adb shell worked.

Many thanks in advance!



More information about the Android-development mailing list