Shell's common script

Source: Internet
Author: User

1 Batch Create users:

#!/bin/bash

I=30

Groupadd Class2

While [$i-le 50]

Do

If ID user$i &>/dev/null

Then

echo "This user$i is exist"

Else

Useradd-g class2 user$i && echo "User$i" | passwd--stdin user$i &>/dev/null && echo "This user$i is created"

Fi

((i++))

Done

2 Detect if the host is alive:

#!/bin/bash

host=192.168.154.

i=120

While [$i-le 130]

Do

Ping-c 3 $host $i &>/dev/null

If [$?-eq 0]

Then

echo "This host $host $i are up"

Else

echo "This host $host $i are down"

Fi

((i++))

Done


3 Get the LAN Ip--mac address list:

#!/bin/bash

host=192.168.154.

I=1

While [$i-le 10]

Do

Arping-c 2 $host $i | Egrep ' Reply ' | Awk-f ' {print $4 $ ' >>/root/c.txt

((i++))

Done


This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1925627

Shell's common script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.