Bonsoir,
J'essaye d'implémenter une méthode qui pourra executer une commande SCP ( copie d'un fichier csv du portable Android vers ma machine locale )
Le code est comme suit:
Instantiation:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class ADBCommand { public String execute(String command) throws IOException { String retour = ""; BufferedReader stdInput = null; BufferedReader stdError = null; System.out.println("execute process"); try { Log.d(TAG, "Executing SCP command"); ProcessBuilder process = new ProcessBuilder("bash", "-c", command); // to execute multiples commands Map<String, String> env = process.environment(); process.redirectErrorStream(true); Process p = process.start(); InputStream is = p.getInputStream(); InputStreamReader isr = new InputStreamReader(is); stdInput = new BufferedReader(isr); String line = ""; while ((line = stdInput.readLine()) != null) { retour += line + "\n"; System.out.println("Results : " + retour); } } catch (Exception e) { Log.e(ERROR, e.toString()); } return retour; } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String command1 = "chmod 777 " + path_to_sdcard + "/" + file_name; String RunSCPcmd = "scp -i /data/data/id_rsa_android /mnt/sdcard/" + file_name + " nbrarou@10.4.0.10:WBESTGit/stage_nabil_brarou/Results"; String command = command1 + " ; " + RunSCPcmd; ADBCommand adb = new ADBCommand(); adb.execute(command); Log.d(TAG, "Running Command " + command); }
J'ai ça dans le LogCat:
y'a quelqu'un qui voit comment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 11-19 17:49:15.530: D/wbest_server(27435): Executing SCP command 11-19 17:49:15.580: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:15.590: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:15.590: I/System.out(27435): Unable to chmod /mnt/sdcard/wbest-estimation_2013-11-19.csv: Operation not permitted 11-19 17:49:16.480: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:16.480: I/System.out(27435): Unable to chmod /mnt/sdcard/wbest-estimation_2013-11-19.csv: Operation not permitted 11-19 17:49:16.480: I/System.out(27435): /system/xbin/ssh: Failed to open /data/local/.ssh/known_hosts 11-19 17:49:16.485: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:16.485: I/System.out(27435): Unable to chmod /mnt/sdcard/wbest-estimation_2013-11-19.csv: Operation not permitted 11-19 17:49:16.485: I/System.out(27435): /system/xbin/ssh: Failed to open /data/local/.ssh/known_hosts 11-19 17:49:16.485: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:16.485: I/System.out(27435): Unable to chmod /mnt/sdcard/wbest-estimation_2013-11-19.csv: Operation not permitted 11-19 17:49:16.485: I/System.out(27435): /system/xbin/ssh: Failed to open /data/local/.ssh/known_hosts 11-19 17:49:16.485: I/System.out(27435): Host '10.4.0.10' is not in the trusted hosts file. 11-19 17:49:16.485: I/System.out(27435): Results : FIX ME! implement ttyname() bionic/libc/bionic/stubs.c:432 11-19 17:49:16.490: I/System.out(27435): Unable to chmod /mnt/sdcard/wbest-estimation_2013-11-19.csv: Operation not permitted 11-19 17:49:16.490: I/System.out(27435): /system/xbin/ssh: Failed to open /data/local/.ssh/known_hosts 11-19 17:49:16.490: I/System.out(27435): Host '10.4.0.10' is not in the trusted hosts file. 11-19 17:49:16.490: I/System.out(27435): (fingerprint md5 72:f6:7b:01:c0:06:b7:71:24:44:5d:e2:b7:d9:d7:e7) 11-19 17:49:17.325: I/AudioPolicyManager(1874): stopOutput() output 1, stream 3, session 4623 11-19 17:49:17.335: I/AudioPolicyManager(1874): startOutput() output 1, stream 3, session 4625 11-19 17:49:17.335: D/AudioSystem(1874): android::AudioSystem::isSeparatedStream(audio_stream_type_t) called!
Merci.
Partager