Home > OS >  Linux script file
Linux script file

Time:11-17

Write to write a script that will be a LAN can ping the IP and classify the IP can't ping and save into two text files (assuming a LAN IP is 10.1.1.1 ~ 10.1.1.254), both the name of a text file using the following format: student's name + pinyin system time to run this script (for example, wangwu2020.5. 8), for a great god help??

CodePudding user response:

The file name of the student's name to manually input

CodePudding user response:

#!/bin/bash
The DATE=` DATE 'm. y. + % % % d' `
Echo $DATE
Read -p "input the student's name" name1
Wj=/$name1 $DATE - up. TXT
Wj1=/$name1 $DATE - the TXT
Touch $wj & amp; & Touch $wj1
The read - p "please enter a network segment to test cases (192.168.16)!" Ipa
For I in {1.. 255}

Do
Ping - c1 - I 0.1 - w1 $ipa. $I & amp;>/dev/null
If [$?=0]; Then
Echo $ipa. $I "up" & gt;> $wj
The else
Echo $ipa. $I "down" & gt;> $wj1
Fi
The done
Echo "connection is successful results in $wj
Failure in $wj1
"
  • Related