Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Detect all network adapters and run commands for each one in bash script?

I have been very busy lately working on scripts for screwing around and i've hit a bit of a wall.
Is there any way to detect EVERY network adapter and for each network adapter found run a specified command? Thanks in advance for any help.
Here you go, bro:

PHP Code

<?php 
interfaces
=`ls /sys/class/net`
read -a ifacearray <<< $interfaces

for i in "${ifacearray[@]}"
do
      :
      echo 
$i
done 

That script gets all network interfaces, iterates through them all, and prints each of them to console on its own line. The interface name is stored in the $i variable, simply pass it as a command parameter.

Running the script:

Code
root@arccot-kali:~# ./s.sh
eth0
lo
wlan0mon
wlan1

The poor remain poor by acting rich.
(Sep 20, 2015 08:51 AM)XMR Wrote:  Here you go, bro:

PHP Code

<?php 
interfaces
=`ls /sys/class/net`
read -a ifacearray <<< $interfaces

for i in "${ifacearray[@]}"
do
      :
      echo 
$i
done 

That script gets all network interfaces, iterates through them all, and prints each of them to console on its own line. The interface name is stored in the $i variable, simply pass it as a command parameter.

Running the script:

Code
root@arccot-kali:~# ./s.sh
eth0
lo
wlan0mon
wlan1

Thank you so much. Thanks to you I finally completed one of my many scripts.
🤗🤗


Possibly Related Threads...
Thread / Author Replies Views Last Post
by IrritiableNov 14, 2021 10:25 AM 7 248 Nov 14, 2021 10:25 AM
Last Post: Exalted
[Kali] by Toretto CMPAug 29, 2019 08:49 AM 0 127 Aug 29, 2019 08:49 AM
Last Post: Toretto CMP
by hack3rconJun 8, 2019 11:20 PM 10 215 Jun 8, 2019 11:20 PM
Last Post: hack3rcon