鉴于我有一个巨大的字符串,让我们说1000行,让我们将该字符串命名为"itext".
我只对"itext"中包含单词"Description:"的那些行感兴趣.例如,在原始"itext"字符串中包含字符串"Description:"的行上仅进行以下替换:
regsub -all -- {Loopback} $itext "Lo" itext ;
Run Code Online (Sandbox Code Playgroud)
有没有办法实现这一点(没有逐行,分裂和加入)?
例如,"itext"可以是这样的:
Loopback11 is up, line protocol is up
Hardware is Loopback
Description: Loopback11-Eigrp-National
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Auto-duplex, Auto-speed
input flow-control is off, output flow-control is off
ARP type: ARPA, ARP Timeout 04:00:00
Last input never, output never, output hang never
Last clearing of "show interface" counters never
Input …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Jcraft Jsch 库通过 Java 应用程序管理路由器。
我正在尝试通过 TFTP 服务器发送路由器配置。问题出在我的 Java 代码中,因为它适用于 PuTTY。
这是我的Java代码:
int port=22;
String name ="R1";
String ip ="192.168.18.100";
String password ="root";
JSch jsch = new JSch();
Session session = jsch.getSession(name, ip, port);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking", "no");
System.out.println("Establishing Connection...");
session.connect();
System.out.println("Connection established.");
ChannelExec channelExec = (ChannelExec)session.openChannel("exec");
InputStream in = channelExec.getInputStream();
channelExec.setCommand("enable");
channelExec.setCommand("copy run tftp : ");
//Setting the ip of TFTP server
channelExec.setCommand("192.168.50.1 : ");
// Setting the name of file
channelExec.setCommand("Config.txt ");
channelExec.connect();
BufferedReader reader = new BufferedReader(new …
Run Code Online (Sandbox Code Playgroud) 我已经搜索了SO以寻求帮助,但找不到我的问题的答案。
情况:我需要将“ / NN”子网掩码表示法(认为IPTABLES)转换为0.0.0.0的cisco表示法。
NN是子掩码中从最低八位字节到较高八位字节的数字“ 1”。每个八位位组是8位整数。
可能的解决方案:
制作一个由32个“ 0”组成的数组,并用“ 1”填充最后一个NN数字,然后分组4个八位字节并转换为int ... / 23掩码应类似于0.0.1.255。
我的问题是如何在.NET中执行此操作...我从未使用过二进制操作和转换。
你们能帮我解决这个问题吗?
更新-斯蒂芬回答正确!
这是移植到.NET的代码
if (p.LastIndexOf("/") < 0 ) return p;
int mask= Convert.ToInt32("0"+p.Substring(p.LastIndexOf("/")+1,2));
int zeroBits = 32 - mask; // the number of zero bits
uint result = uint.MaxValue; // all ones
// Shift "cidr" and subtract one to create "cidr" one bits;
// then move them left the number of zero bits.
result &= (uint)((((ulong)0x1 << mascara) - 1) << zeroBits);
result = ~result;
// …
Run Code Online (Sandbox Code Playgroud) 我想向您寻求帮助:有人知道如何通过 tcpdump 检测思科发现协议吗?
目前我正在使用以下命令,但我不确定:
tcpdump -i eth0 -nn "ether[20:2]==0x2000"
Run Code Online (Sandbox Code Playgroud)
一些提示值得赞赏。谢谢 ...
恰克
因此,在进行糊涂之后,似乎有很多人说您无法使用Wireshark在Packet Tracer中捕获模拟中的数据包。但是,我的教授给了我这份作业。
我似乎无法弄清楚。
场景:
已链接2台计算机(192.168.1.1和192.168.1.2)。我从PC 1(192.168.1.1)ping通到PC2。我想捕获这些数据包。我将如何处理他?
据我所知,有以下协议用于发送和接收电子邮件:
这些协议中的哪些用于在电子邮件中发送附件?发送电子邮件时 FTP 或 TFTP 有什么作用吗?
networking network-programming cisco protocols email-attachments