我正在使用 gammu 发送短信,我想知道是否可以使用两台或多台带有 java 应用程序的计算机同时发送消息。我尝试了 10 次,并且 10 次中有 1 次从两台计算机成功发送了消息。9次只有一台计算机可以发送短信而另一台无法发送。是否有某种设置或命令,以便我可以同时从这两台计算机发送消息?对于配置,我使用 Gammu 的默认配置
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
public class TestingSms {
public static void main(String[] args) {
// TODO Auto-generated method stub
String host = "MY GAMMU IP";
String user = "MY USERNAME";
String password = "MY PASSWORD";
int port = 22;
String sms ="haloo";
JSch jsch = new JSch();
try {
Session session = jsch.getSession(user, host, port);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
ChannelExec exec = (ChannelExec) session.openChannel("exec");
exec.setCommand("gammu sendsms TEXT 08xxxxxxxxxx -text \""+sms+"\"");
exec.setErrStream(System.err);
exec.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
String temp;
while((temp=reader.readLine())!=null) {
System.out.println(temp);
}
exec.disconnect();
session.disconnect();
System.out.println("\n\nFinish");
} catch (JSchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
失败消息:
Warning: No configuration read, using builtin defaults!
No response in specified timeout. Probably phone not connected.
先感谢您