string[] tokens = stringVariable.Split('\r');
那如果
stringVariable.Split(new string[] { "\r\n" }, StringSplitOptions.None);
string[] tokens = stringVariable.Split('\r');
那如果
stringVariable.Split(new string[] { "\r\n" }, StringSplitOptions.None);
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import snmp.SNMPBadValueException;
import snmp.SNMPGetException;
import snmp.SNMPObject;
import snmp.SNMPObjectIdentifier;
import snmp.SNMPOctetString;
import snmp.SNMPSequence;
import snmp.SNMPVarBindList;
import snmp.SNMPv1CommunicationInterface;
/**
*
* @author Derek.Li
*/
public class SnmpGet {
public static void println(int level, String context) {
if (level > 0) {
return;
}
System.out.println(context);
}
// public final String itemID = "1.3.6.1.2.1.1.1.0";
public String snmpGet(String IP, String community, String OID) {
try {
InetAddress hostAddress = InetAddress.getByName(IP);
int version = 0; //設定0的時候為使用snmpv1
SNMPv1CommunicationInterface comInterface = new SNMPv1CommunicationInterface(version, hostAddress, community);
comInterface.setSocketTimeout(5000); //ms = 1/1000 s
// the getMIBEntry method of the communications interface returns an SNMPVarBindList
// object; this is essentially a Vector of SNMP (OID,value) pairs. In this case, the
// returned Vector has just one pair inside it.
SNMPVarBindList newVars = comInterface.getMIBEntry(OID);
// extract the (OID,value) pair from the SNMPVarBindList; the pair is just a two-element
// SNMPSequence
SNMPSequence pair = (SNMPSequence) (newVars.getSNMPObjectAt(0));
// extract the object identifier from the pair; it's the first element in the sequence
SNMPObjectIdentifier snmpOID = (SNMPObjectIdentifier) pair.getSNMPObjectAt(0);
// extract the corresponding value from the pair; it's the second element in the sequence
SNMPObject snmpValue = pair.getSNMPObjectAt(1);
// print out the String representation of the retrieved value
String result = snmpValue.toString();
if(OID.equals("1.3.6.1.2.1.2.2.1.6.2"))
return ((SNMPOctetString)snmpValue).toHexString();
return result;
} catch (Exception e) {
String result = null;
return result;
}
}
}
Process process = new Process();process.StartInfo.FileName = "cliprogram.exe";process.StartInfo.UseShellExecute = false; //如果輸出導向的話此處要設定process.StartInfo.RedirectStandardOutput = true;process.StartInfo.RedirectStandardInput = true;process.Start();有些開發的程式在python 3.8的檔案套件不相容,例如pymssql,等。 所以如果不建置虛擬環境的話才特意安裝3.7版本的python 安裝流程如下 # 先進行yum套件的update yum update -y # 安裝相依性套件 yum install gcc o...