Getting Variable Integer Values From Grep

I want to write a Python script. In order to write it I need to figure out how to access the values associated with my signal level and bit rate.

If I use the following command

Code:
iwconfig | grep 'Signal level'

I get:

eth0 no wireless extensions.

lo no wireless extensions.

Link Quality=70/70 Signal level= -38 dBm


Obviously, I don't want Signal level. I want whatever it happens to be. In this case, it happens to be -38. Ditto Bit Rate...How do I grab -38 from the command line?


Similar Content



How Do I Select With Grep And Awk Only ONE Text Content In A Script

i got a nasty isue here.
for my machine i want to make a checkup script to see to what wireless network i am connected to.

if i type iwconfig i get below output.
Code:
 iwconfig
wlan0     IEEE 802.11bgn  ESSID:"APqwerty"
          Mode:Managed  Frequency:2.447 GHz  Access Point: 72:6B:D3:36:29:44
          Bit Rate=54 Mb/s   Tx-Power=20 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=55/70  Signal level=-55 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:7339  Invalid misc:83573   Missed beacon:0

lo        no wireless extensions.

eth0      no wireless extensions.

With a grep awk combo i manage to narow it down.
Code:
  iwconfig | grep ESSID |awk '{ /ESSID/; print $4 }'
lo        no wireless extensions.

eth0      no wireless extensions.

ESSID:"APqwerty"

why it also shows lo and eth0 ,i dont know, but ok.

i tried several combo's on grep, awk, even cut.
i only want to catch the ESSID to where i am connected to, in this case APqwerty.
i know i am missing something, but cant find out what it is, any advice ?

Calculation Using Variable Inside Variable

I have some variables which have stored numerical values like
Quote:
A1=10 A2=20 A3=25
B1=10 B2=15 B3=12 and so on
As well as another set of variables which stored these variables like
Quote:
var1=A1 var2=A2 var3=A3
var4=B1 var5=B2 var6=B3 and so on
I have to calculated things using second set of variable.
In the script, there is line
Code:
read number

user will enter number manually, suppose 500
I have to calculate using
Code:
expr 500 \* ${$var1} / 100

and output of this multiplied by
Code:
expr $above_output \* ${$var2} /100

and output of this multiplied by
Code:
expr $above_output \* ${$var3} /100

But not able to deal with two levels of variable. The calculation will be hard when it comes for three level and four level.

Please help.

Network Manager States That I Am Connected, But I Cannot Connect To Any Webpage

Hey all,

I just did a Debian minimal install and am using the package network-manager-gnome to manage wifi. I should also mention I'm running OpenBox. Anyway, network-manager shows up just fine in my systemtray and it lets me connect and displays that I am connected in the system tray. However, when I try to connect to a website it will just say "connecting" for a very long time before timing out. Note that my ethernet works perfectly.

If it helps, this is what shows up in iwconfig after I've "connected" to a network through network-manager:

Code:
wlan0     IEEE 802.11abgn  ESSID:"The Stack Resident Wifi"  
          Mode:Managed  Frequency:5.24 GHz  Access Point: 54:3D:37:02:A5:CC   
          Bit Rate=13 Mb/s   Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=33/70  Signal level=-77 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:154   Missed beacon:0

I've searched in many places and I couldn't find someone who had a similar problem. Any help would be awesome. Thanks!

How To Read The Signal Queue Of A Process??

Hi,

I am not completely new to linux.

My problem is the following:

The signal queue of my process gets filled with time.

With /proc/PID/status --> SigQ 6032/6032 i can see that the queue is full!

And my software is waiting on signals to process data. So I want to know wich signal filled my queue and I am interested to see the attached data of the signal --> sival_int or sival_ptr, I use sigwaitinfo() to read the data.

How To Run A Command In Another Command?

I am not sure how to ask this, sorry.

if I had a code like this

Code:
# grep -a ": " md5list.txt | cut -f2,3 -d


How can I run the command basename for each line of the output?

basename {(grep -a ": " md5list.txt | cut -f2,3 -d )}


EDIT: A little more clarity on what im doing:
I didn't realize that 'md5sums' was a link to a nice formatted page. So I copied all packages here and put them into a text file. I decided to write a script that put all of these in that format.

So basically, even though I have already ran the md5sum -c 'md5sum-list' I still want to finish this small project because I am learning a ton.

Wireless Fail - Netgear Wg311t On Xubuntu

The most recent info on this card is about 10 years old.

The story is that I had an old dying PC with a vast accumulation of dust, causing sparks to fly.
I transferred the disk & wireless card across to a "known good PC" - and "amazingly" it worked.

This lasted for about a week.
OS is Xubuntu 12.04 and recommended updates of an unknown nature were applied from repositories & PPA's (not by me).

Soon after, wireless on the ancient Netgear wg311t PCI card failed.
I've tried moving it to a different slot - still does not work.
I've tried booting up from a Xubuntu 14.04.2 DVD - still does not work.
The two slots give slightly different results to the command Code:
dmesg | grep ath5k

First slot Code:
[   63.714417] ath5k 0000:05:06.0: registered as 'phy0'
[   63.733142] ath5k: phy0: failed to wakeup the MAC Chip
[   63.733482] ath5k: probe of 0000:05:06.0 failed with error -5

Second slot Code:
[   13.594859] ath5k 0000:05:08.0: PCI INT A -> Link[APC3] -> GSI 18 (level, low) -> IRQ 18
[   13.594943] ath5k 0000:05:08.0: registered as 'phy0'
[   13.606136] ath5k phy0: failed to wakeup the MAC Chip
[   13.606531] ath5k 0000:05:08.0: PCI INT A disabled
[   13.606768] ath5k: probe of 0000:05:08.0 failed with error -5

I'm prepared to buy a replacement card - so long as it is cheap!

Quick GREP Question..

Hey guys,

Something is puzzling me!

I saw someone use the grep in the following way and I'm not sure I understand what it does, and if there's any benefit to using it this way.

Code:
grep X.X.X.X /var/log/log.log | grep -v query

I checked the man file which confirmed that -v is relating to matching non grouping lines (which I'm not sure I fully understand either!) but I don't see any difference in the output of the above command versus the same command without the | grep -v query bit..

Why would you pipe grep into grep unless you were searching for something specific within the search results?

Does query mean something else?

Question About Run Level Programs And How The OS Know What To Run

Hey guys, I am a little confused about run level programs. (concerning centos)

I know when the system boots up the orders will be

bios
MBR
GRUB
kernel
init
runlevel

to my understanding - etc/init looks at /etc/inittab
then where is the run level located?
is it /etc/rc.d/rc0.d...
/etc/rc.d/rc1.d
/etc/rc.d/rc2.d
are these run level programs?

if so, what about /etc/init.d ? doesnt that also execute run level programs?

and how does it know what to start? where does it look

thanks guys just a bit confusing where what looks for what

Please Interpret The Meaning Of This Command

Hi ,

Please explain what the below command means ..


Code:
if grep -c -i Y $INIFILE > /dev/null

I know what is the use of grep, it is used for finding a character or string in a file. But i could not understand the above form of grep command.

I am new to linux so this might be a simple question, but please throw some light on it.


Edited

And also please explain why they are creating a file in null in the below command

Code:
cat /dev/null > $DATA_DIR/$DATAFILE

What Is A Signal 11 Error And How Do I Fix This?

Several of the apps are intermittently hanging and I am getting "Signal 11 error" messages. What is this error and what do I need to do about it?