Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

Looking for help regarding a bash script

Solved! Go to Solution.

Hi everyone :)

I am looking for some informations regarding a bash script.

I am using the commande lspi | grep -i net to get information toward network components.

My script is the following :

 

Capture du 2019-07-26 14-29-17.png

Rm allows me to reset the text file I am creating each time I run the script (or else it will keep adding in the file text without clearing it) [If you have any ways to do it better, I am taking it !]

 

This script is suppose to allow me to know if there is a wifi card, or not (and it works that way) and will be a part of a bigger one for several informations, to make a paper that will be automatically printed and fullfilled.

 

My problem here is that I would like to copy paste to "Network Controller" line and informations into a text file (or have it in any way)

I tried multiple things but Ican't find any way to do so, atleast from the terminal itself

 

Would anyone have any tips about doing that ?

 

Thanks in advance

2 Replies
Copilot Lvl 2
Message 2 of 3

Re: Looking for help regarding a bash script

Now using the following line

echo $Wifi > txt.txt

to get the information from the command

But I cant get to know how to select specifically the network controller line only, anyone has a clue for it ?

Solution
Commander Lvl 2
Message 3 of 3

Re: Looking for help regarding a bash script

Hi @Ellaina22,

 

You can replace your script with this:

 

#!/bin/bash

Wifi=$(lspci | grep -i net | grep 'Network controller');

if [[$Wifi == *"Network controller"*]];
then
echo "|Wifi ON| |" > wifion.md;
else
echo "|NO Wifi| |" > nowifi.md;
fi

the line with the declaration of the Wifi retrive only the 'Network controller' line and than inside the if controll statement you need to replace the >> with only one >, this rewrite completely the file and you can remove the first two line of remove.

 

Hope this help, ask if you need farther infos...

 

-Gabriele-

 

Mark helpfull posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great contents!