Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ping host ip address, judgment and automatic installation of sysstat software packages and other scripts

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The ip address of the ping host. Return the result

Vi pinghost.sh

#! / bin/bash

Ping-c 3-I 0.2-W 3 $1 & > / dev/null

If [$?-eq 0]

Then

Echo "Host $1 is up."

Else

Echo "Host $1 is down."

Fi

Sh pinghost.sh ip address

Judge the interval of the score, and give different grading results.

#! / bin/bash

Read-p "Please enter your score (0-100):" GRADE

If [$GRADE-ge 85] & & [$GRADE-le 100]; then

Echo "$GRADE score! excellent"

Elif [$GRADE-ge 70] & & [$GRADE-le 84]; then

Echo "$GRADE score, qualified"

Else

Echo "$GRADE score? not qualified"

Fi

5. Write a script named chkinstall.sh to judge the installation of the sysstat software package in the system, and if it has been installed, prompt "installed" and output the sysstat version information; otherwise, prompt "not installed, try to install automatically" and visit the CD mount point / media/cdrom/Pachages to install the sysstat software automatically.

#! / bin/bash

Rpm-Q sysstat & > / dev/null

If [$?-eq 0]

Then

Echo "installed 'rpm-Q sysstat'"

Else

Echo "not installed, try to install automatically"

RHEL_DIR= "/ mntrom/Server/"

If [- d $RHEL_DIR]

Then

Cd $RHEL_DIR

Rmp-ivh sysstat-*.rpm & & echo "installation is complete."

Else

Echo "error: unable to access CD directory: $RHEL_DIR"

Fi

Fi

4. Judge the major and minor kernel versions of the current system, and output the corresponding information if it is greater than 2.4, otherwise the output "the kernel version is too low to continue"

Vi cheversion.sh

#! / bin/bash

Mnum=$ (uname-r | awk-F. '{print $1}')

Snum=$ (uname-r | awk-F. '{print $2}')

If [$Mnum-eq 2] & & [$Snum-gt 4]

Then

Echo "kernel version is: $Mnum.$Snum"

Else

Echo "the kernel version is too low to continue!"

Fi

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report