i have a problem in this code
public void setTmbhUserFtp(View v) {
Spinner spinner = (Spinner) findViewById(R.id.spinner);
Server server = serverlist.get(spinner.getSelectedItemPosition() - 1);
EditText EditAdduser = (EditText) findViewById(R.id.EditAdduser);
EditText EditPassworduser = (EditText) findViewById(R.id.EditPassworduser);
String sTextAdduser = EditAdduser.getText().toString();
String sTextPassworduser = EditPassworduser.getText().toString();
if (server != null && sTextAdduser.length() > 0
&& sTextPassworduser.length() > 0) {
final String ADDUSER = "sh /home/add_user.sh".concat(sTextAdduser) .concat(sTextPassworduser);
FtpConnect u = new FtpConnect();
Command o = new Command(getResources().getText(R.string.adduser)
.toString(), ADDUSER, server);
u.setCommand(ADDUSER);
pd = ProgressDialog.show(actual,
getResources().getString(R.string.PleaseWait), o.getName());
actualThreadCommand = o;
Thread thread = new Thread(actual);
thread.start();
} else {
Toast.makeText(getBaseContext(),
getResources().getText(R.string.gagal), Toast.LENGTH_LONG)
.show();
}
}
that code is using for excute in linux like this
sh /home/add_user.sh username password
but when i try from my android the username and password is being one
so the code is like this
sh /home/add_user.sh usernamepassword
if username is irfan and password is irfan, the code is detect
sh /home/add_user.sh irfanirfan
so username being irfanirfan and dont have a password
the code add_user.sh is
useradd $1; echo -e "$2\n$2" | passwd $1
how to resolving
final String ADDUSER = "sh /home/add_user.sh ".concat(sTextAdduser) .concat(sTextPassworduser);
after .concat(sTextAdduser) must be space
so in linux will excute
sh /home/add_user.sh irfan irfan
This way you may solve your problem: