die sache verhält sich im detail folgendermaßen. ich nutze um das
programm zu öffnen die pstream lib welche auf popen aufsetzt.
(http://pstreams.sourceforge.net/)
öffne ich damit als beispiel ifconfig:
1 | std::string s, ausgabe;
|
2 | redi::pstream ifconfig("ifconfig -a");
|
3 | while(std::getline(ifconfig, s)) {
|
4 | ausgabe.append(s);
|
5 | ausgabe.append("\n");
|
6 | }
|
7 | textview_buffer->set_text(ausgabe);
|
landet der konsolenoutput wunderbar im string ausgabe und wird meinem
gtk widget zugefügt.
ich will aber nicht ifconfig anzeigen. mein programm startet ein android
sdk tool welches unterschiedliche parameter hat. mit einem der parameter
geht es. dieser parameter öffnet eine shell zum android device und ich
kann problemlos infos hin und her schieben
1 | std::string s, ausgabe;
|
2 | chdir(path_to_adb.c_str());
|
3 | redi::pstream adb_shell("./adb shell");
|
4 | adb_shell << "mount /system" << std::endl;
|
5 | adb_shell << "chmod 644 /system/app/*" << std::endl;
|
6 | adb_shell << "chmod 644 /system/framework/*" << std::endl;
|
7 | adb_shell << "exit" << std::endl;
|
8 | while(std::getline(adb_shell, s)) {
|
9 | ausgabe.append(s);
|
10 | ausgabe.append("\n");
|
11 | }
|
12 | textview_buffer->set_text(ausgabe);
|
folgende anweisung geht aber nicht. dieses mal wird keine shell geöffnet
sondern durch das android tool der inhalt eines ordners datei für datei
gepushed.
1 | std::string s, ausgabe;
|
2 | std::string system_app;
|
3 | std::string copy_apps;
|
4 | system_app = "ls ";
|
5 | system_app.append(path_to_binary);
|
6 | system_app.append("/system/app/");
|
7 | redi::ipstream ls(system_app);
|
8 | while (ls >> copy_apps) {
|
9 | chdir(path_to_adb.c_str());
|
10 | std::string command = "./adb push ";
|
11 | command.append(path_to_binary);
|
12 | command.append("/system/app/");
|
13 | command.append(copy_apps);
|
14 | command.append(" /system/app/");
|
15 | redi::pstream adb_push(command);
|
16 | while(std::getline(adb_push, s)) {
|
17 | ausgabe.append(s);
|
18 | ausgabe.append("\n");
|
19 | }
|
20 |
|
21 | textview_buffer->set_text(ausgabe);
|
22 | }
|
der unterschied zwischen der 2. und 3. anweisung ist eigentlich nur der,
das adb shell eine dauerhafte verbindung aufbaut in welche ich schreiben
und lesen kann. adb push hält keine verbindung offen. es kopiert die
datei und damit ist die sache abgeharkt. aber auch adb push gibt auf der
konsole output über die kopierten daten und wie lange es gedauert hat.
ich komme halt nur nicht ran.