在线shell脚本(写个LINUX的SHELL 脚本,要求:PING 一个网站地址,把结果写到另一个文本文件中,怎么写,请教,在线等)

本文目录
- 写个LINUX的SHELL 脚本,要求:PING 一个网站地址,把结果写到另一个文本文件中,怎么写,请教,在线等
- centos 7 shell 脚本怎样运行
- linux 中如何使用shell 脚本执行 telnet
- Linux下nmap扫描端口shell脚本
写个LINUX的SHELL 脚本,要求:PING 一个网站地址,把结果写到另一个文本文件中,怎么写,请教,在线等
ping -c 5 www.baidu.com 》ping.txt,其中通断过程可以用grep命令从txt文件中查找并加以判断。
centos 7 shell 脚本怎样运行
一、root权限/etc/rc.d/rc.local
Shell代码
su
cd /etc/rc.d/
vi rc.local
二、在这个文件加上你要执行的脚本,全部内容如下:
Shell代码
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
mount //192.168.0.3/data2-1 /mnt/data2-1 -o username=un,password=123
mount //192.168.0.3/data2-2 /mnt/data2-2 -o username=un,password=123
mount //192.168.0.3/data2-3 /mnt/data2-3 -o username=un,password=123
mount //192.168.0.3/data2-4 /mnt/data2-4 -o username=un,password=123
mount //192.168.0.3/data2-5 /mnt/data2-4 -o username=un,password=123
提示:这里的做法很不成熟,希望不要这样,最好自己写个脚本文件在这里来调用,结构更清晰,但是要注意到是把要执行的命令作为一个参数传递给su。
另外复习一个VI命令-拷贝
yy
p
linux 中如何使用shell 脚本执行 telnet
登录并备份到tftp的脚本是这个奶奶样的:
#!/usr/bin/expect
spawn telnet 10.21.10.233
expect "*sername*"
send "admin\r"
expect "*asswor*"
send "******\r"
send "en\r"
expect "*assw*"
send "*******\r"
send "copy running-config startup-config\r"
expect "*estination filename*"
send "\r"
send "copy startup-config tftp:\r"
expect "*ddress or name of remote host*"
send "10.21.10.110\r"
expect "*estination filename*"
send .config\r
sleep 10
send "exit\r"
send "\r"
Linux下nmap扫描端口shell脚本
安装nmap后(ubuntu通过apt-get install nmap安装),运行下列命令即可
nmap -p0-65535 目标ip地址
常用的扫描类型:
1、-sP(ping的方式扫描,检查主机在线与否,不发送任何报文到目的主机,想知道目标主机是否运行,而不想进行其它扫描,这扫描方式很常用)
2、-sL(仅仅列网段内出主机的状态、端口等信息,查询端口的话用 -p port,port1……)
3、 -PS/PA/PU (根据给定的端口用TCP或UDP报文探测:对于root用户,这个选项让nmap使用SYN包而不是ACK包来对目标主机进行扫描。如果主机正在运行就返回一个RST包(或者一个SYNACK包))
4、-sS(TCP同步扫描(TCP SYN):发出一个TCP同步包(SYN),然后等待回对方应)
5、 -sF -sF -sN(秘密FIN数据包扫描、圣诞树 (Xmas Tree)、空(Null)扫描模式使用-sF、-sX或者-sN扫描显示所有的端口都是关闭的,而使用SYN扫 描显示有打开的端口,你可以确定目标主机可能运行的是Windwos系统)
6、-sU(UDP扫描:nmap首先向目标主机的每个端口发出一个0字节的UDP包,如果我们收到端口不可达的ICMP消息,端口就是关闭的,否则我们就假设它是打开的)
7、-P0 (No ping)(这个选项跳过Nmap扫描)
8、-PE/PP/PM
扫描类型的控制
1、sW (对滑动窗口的扫描)
2、-sR(RPC扫描)
3、 -PE; -PP; -PM (ICMP 类型的ping)
4、-PR (ARP 类型的ping-n (无 DNS 解析)
5、-R (为所有的目标做DNS解析)
6、-sV(对服务版本的检测)
常用的对主机的操作
1、-A或者-O(对操作系统的检测)
2、-v(增加信息的详尽程度)
3、-p(ports的范围)

更多文章:
在线shell脚本(写个LINUX的SHELL 脚本,要求:PING 一个网站地址,把结果写到另一个文本文件中,怎么写,请教,在线等)
2026年10月3日 09:40
pipeline flex(pipeline flex(Ev3)走社保可以报销吗)
2026年10月3日 07:30
ignorecase false(iis php伪静态怎么设置)
2026年10月3日 05:50
资源付费网站源码(购买一个网站一般给源码不,现在没有源码了,可以有什么办法找到源码)
2026年10月3日 03:30






