Ifconfig p32p1|egrep-o "broadcast [^]*" |grep-o "[0-9.] *"
Grep-o "Broadcast [^]*" marked starting with broadcast, with non-empty characters (specified by [^]*) as the end of the sequence,
[0-9.] mark the number and dot, followed by * If you do not add each number to one line
Find active IP addresses in the network
#!/bin/sh
# () & Background parallel execution
#wait wait for all subroutines to end
For IP in 192.168.5. {21..254};
Do
(
Ping $ip-c2 &>/dev/null;
If [$?-eq 0]
Then
Echo $ip is alive
Fi
) &
Done
Wait
can be obtained by fping and Nmap commands
Automatically transfer files
[Email protected] root]# cat/usr/local/bin/r_ftp
#!/bin/bash
User=root
Pass=password
server=192.168.5.23
Rpath= "/web/cgi-bin/"
Sourcefile=$1
Ftp-n << EOF
Open $SERVER
User $USER $PASS
Binary
Hash
CD $RPATH
Put $SourceFile
Bye
Eof
Find active IP in the network and automatically transfer text