Probléme Commande SSH "jeebop.sh"

cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009 - 31 oct. 2008 à 10:58
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 - 13 nov. 2008 à 17:21
Bonjour à tous,

Afin d'envoyer la commande "jeebop.sh stop" en ssh, j'ai testé 3 api différentes et j'ai toujours rencontré le même probléme : un simple "ls" fonctionne parfaitement tandis que "jeebop.sh stop" pose probléme (la commande ne s'éxécute pas").

Ma question est donc : cette commande doit elle bénéficier d'un traitement particulier pour pouvoir être exécutée ?

Merci à tous :)

8 réponses

cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009
31 oct. 2008 à 11:12
Apparement c'est l'espace entre le jeebop.sh et la commande (ici "stop") qui fait foirer le truc.

Donc si quelqu'un sait comment résoudre cela ;)
0
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 17
31 oct. 2008 à 15:08
ben heu c'est pas du java pure mais moi si je fais en ssh:

ssh root@dev3 invoke-rd.c apache2 restart
ca marche impec

t'as pas besoin de preciser le path de ton script ?
apres je connais pas les apis ...

"n'est pas mort ce qui semble a jamais dormir et en d'etrange temps meme la mort peut mourrir"
0
cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009
31 oct. 2008 à 17:01
Bon apparament ce n'est pas le passage d'argument qui géne puisque si j'en met un au hasard j'ai bien retour d'erreur envoyé par le serveur (ex: "jeebop.sh ratus" me renvoit une erreur m'indiquant que l'argument doit être status start stop ou restart).
Bizarre tout ça...
0
cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009
4 nov. 2008 à 10:34
Toujours rien?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 17
4 nov. 2008 à 10:38
nop mais dis quel lib tu utilises, des morceaux de code quoi

"n'est pas mort ce qui semble a jamais dormir et en d'etrange temps meme la mort peut mourrir"
0
cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009
4 nov. 2008 à 16:07
bah comme je l'ai expliqué j'ai testé 3 lib différentes avec toujours le même probléme.

Je suis resté sur com.sshtools.j2ssh.
Voilà le code de mon appli :

import java.io.InputStream;
import java.io.OutputStream;

import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.session.SessionChannelClient;



public class SshExample {

private static String hostname = "hostname";
private static String username = "user";
private static String password = "pass";




public static void main(String args[]) {
try {
// Further code will be added here
SshClient ssh = new SshClient();
ssh.connect(hostname);

PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();

pwd.setUsername(username);
pwd.setPassword(password);

int result = ssh.authenticate(pwd);

if(result==AuthenticationProtocolState.FAILED)
System.out.println("The authentication failed");

if(result==AuthenticationProtocolState.PARTIAL)
System.out.println("The authentication succeeded but another"
+ "authentication is required");

if(result==AuthenticationProtocolState.COMPLETE)
System.out.println("The authentication is complete");

SessionChannelClient session = ssh.openSessionChannel();
session.executeCommand("jeebop/bin/jeebop.sh restart");

/** Writing to the session OutputStream */
OutputStream out = session.getOutputStream();
String cmd = "ls\n";
out.write(cmd.getBytes());


/**
* Reading from the session InputStream
*/
InputStream in = session.getInputStream();
byte buffer[] = new byte[255];
int read;
while((read = in.read(buffer)) > 0) {
String out2 = new String(buffer, 0, read);
System.out.println(out2);
}




} catch(Exception e) {
e.printStackTrace();
}




}

}
0
cs_Micke7 Messages postés 17 Date d'inscription jeudi 21 septembre 2006 Statut Membre Dernière intervention 2 avril 2009
4 nov. 2008 à 16:11
Normal que ce soit illisible comme ça?
Je teste avec la textbox normal.

import java.io.InputStream;
import java.io.OutputStream;

import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.session.SessionChannelClient;



public class SshExample {
private static String hostname = "serveur";
private static String username = "user";
private static String password = "pass";

public static void main(String args[]) {
try {
// Further code will be added here
SshClient ssh = new SshClient();
ssh.connect(hostname);

PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
pwd.setUsername(username);
pwd.setPassword(password);

int result = ssh.authenticate(pwd);
if(result==AuthenticationProtocolState.FAILED)
System.out.println("The authentication failed");
if(result==AuthenticationProtocolState.PARTIAL)
System.out.println("The authentication succeeded but another" +n+ "authentication is required");

if(result==AuthenticationProtocolState.COMPLETE)
System.out.println("The authentication is complete");

SessionChannelClient session = ssh.openSessionChannel();
session.executeCommand("jeebop/bin/jeebop.sh restart");
//session.executeCommand("jeebop/jeebop/bin/jeebop.sh stop");

/** Writing to the session OutputStream */
OutputStream out = session.getOutputStream();
String cmd = "ls\n";
out.write(cmd.getBytes());


/**
* Reading from the session InputStream
*/
InputStream in = session.getInputStream();
byte buffer[] = new byte[255];
int read;
while((read = in.read(buffer)) > 0) {
String out2 = new String(buffer, 0, read);
System.out.println(out2);
}
} catch(Exception e) {
e.printStackTrace();
}
}

}
0
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 17
13 nov. 2008 à 17:21
dans le executeCommand t'en aurais pas dautre qui aurais comme prototype un truc du genre :

executeCommand(string command, string params)

?

Sinon je peux pas vraiment t'aider ne connaissant pas la lib

"n'est pas mort ce qui semble a jamais dormir et en d'etrange temps meme la mort peut mourrir"
0
Rejoignez-nous