?? runcommand.java
字號:
/*
* RunCommand.java
*
* Copyright (C) 2004 Jay Scott
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (gpl.txt); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package commands;
import config.ConfigManager;
import java.io.File;
import java.io.FileInputStream;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import ui.ServerGUI;
/**
*<p>
*This class runs the required system command and then sends the output back
*to the ServerAccept class.
*</p> <p>
*
*@author Jay Scott
*@created July 21, 2004
*@version 0.4
*@see java.io.BufferedReader
*@see java.io.IOException
*@see java.io.InputStreamReader
*/
public class RunCommand {
/**
* This method runs the selected command
*
* @param runCMD
* The query sent to the server
* @return The WML output for the query executed
*/
public String runCommand(String runCMD) {
Format TimeFormat;
Date date = new Date();
TimeFormat = new SimpleDateFormat("hh:mm:ss a");
String theTime = TimeFormat.format(date);
String cmd = runCMD;
String outputWML = "";
String defaultWML = ("<?xml version='1.0'?>"
+ "<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN'"
+ " 'http://www.wapforum.org/DTD/wml_1.1.xml'>"
+ "<wml><template><do type='options' name='prev' label='Back'>"
+ "<prev/></do></template><card title='Failed' id='first'>"
+ "<p align='center'><br/>Command Failed!<br/>"
+ "<a href='menu'>Continue</a><br/>" + "</p></card></wml>");
ConfigManager cfg = new ConfigManager();
if (cmd.equals("")) {
cmd = "login";
}
if ((cmd.substring(3)).equals(cfg.getPasscode())) {
cmd = "loggedin";
}
try {
Properties config = new Properties();
config.load(new FileInputStream(System.getProperty("user.dir")
+ File.separatorChar + "commands" + File.separatorChar
+ cmd + ".cmd"));
outputWML = config.getProperty("WML");
String inputCMD = config.getProperty("Command");
String outputGUI = config.getProperty("GUI");
if (!(inputCMD == null)) {
try {
Process x = Runtime.getRuntime().exec(inputCMD);
} catch (Exception e) {
}
}
ServerGUI.StatusText.append('[' + theTime + ']' + " - " + outputGUI
+ '\n');
} catch (Exception e) {
ServerGUI.StatusText.append('[' + theTime + ']'
+ " - Invalid Server Command Sent!\n");
return defaultWML;
}
return outputWML;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -