[Solved] Could someone that knows awk good fix this script for me?

I found this script on the linuxquestions site that tests and displays network bandwidth.  There's an error in the script though and my awk experience isn't enough to debug it and is giving me the error:
awk: cmd. line:10: printf ("%4.0f", Ratio)}
awk: cmd. line:10: ^ syntax error
awk: cmd. line:10: printf ("%4.0f", Ratio)}
awk: cmd. line:10: ^ syntax error
^C/home/todd/.bin/bandwidth-test: line 21: [: : integer expression expected
BW Surchargé - Moyenne de de Kb/sec pendant 20 secondes
This is the script:
#!/bin/bash
# bandwidth-test - test bandwidth from the command line
Fic_Tmp="/tmp/Fic_Tmp_VerifRatio.tmp"
NbrSec=20
/usr/bin/bwm-ng -I eth0 -o csv -T avg -C " " -c ${NbrSec} | awk '
BEGIN{
BytesS=0
NbrLecture=0}
/eth0/&&NR>2{
BytesS+=$5/1024
NbrLecture+=1}
END{
Ratio=BytesS/NbrLecture
printf ("%4.0f", Ratio)}' > ${Fic_Tmp}
Ratio=$(cat ${Fic_Tmp})
rm ${Fic_Tmp}
if [ "${Ratio}" -lt 110 ];then
echo "BW OK - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
exit 0
else
echo "BW Surchargé - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
exit 2
fi
exit $?
Anyone available to fix this for me?
Last edited by Gen2ly (2009-11-17 17:52:14)

Ah, thought I counted all those.  Whoops .  Yep that did the trick.  Thanks benob.
Edit: Just FYI to any that read this.  This script only checks if you are in the cap range, so it's not really a bandwidth tester for the command line.  The nearest I've found is 'iperf' which I'm unable to get to use yet.
Edit2 : netperf seems better suited for this, only been able to learn how to do download speed test so far:
netperf -c hostname -f K
Last edited by Gen2ly (2009-11-17 19:08:38)

Similar Messages

  • My sons ipod touch apps will not load. you touch them the title screen for the game flicks up then dissappears. Could someone please tell how to fix this or what could be wrong?

    My sons ipod touch apps and games will not play. when you touch to game to load it the title screen flicks up and then disappears. please could someone help me to fix this problem or tell me what could be wrong?

    I would first try resetting your iPod. Nothing will be lost.
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.

  • Is there an and in original box with cables. Item cannot be activated because of cloud lock. Preof cloud lockvious user login is UNKNOWN. Unit is sold as is for parts or use by someone who knows how to fix this issue

    Amazon has a refurbed I pad Air with this remark. Item cannot be activated because of cloud lock previous user login unknown. Is there a work around or is it best to forget this one and move on?

    You are welcome, at least the seller was honest enough to let potential buyers know that the device is useless to anyone who would try to buy it.

  • HT201210 I am trying to update my iPhone but it seems that I have to many photos and music because I received the following message: The iPhone could not be updated; this device is not elegible for the requested build. Does anyone know how to fix this?

    I am trying to update my iPhone but it seems that I have to many photos and music because I received the following message: The iPhone could not be updated; this device is not elegible for the requested build. Does anyone know how to fix this?

    You have to delete the corrupt back-up so iTunes can at least back-up the current data on the iPhone and then restore it. Search these forums, there a several good posts on how to delete the corrupt back-up.

  • When I connect my iPod nano 7th gen. to my computer and open itunes, there is a message that says the iPod could not be detected. Does anybody know how to fix this issue?

    When I connect my iPod nano 7th gen. to my computer and open itunes, there is a message that says the iPod could not be detected. Does anybody know how to fix this issue?

    1. Update iTunes to the latest version. Plug in your iPod. If iTunes still can't recognize it, then in iTunes in the top left corner click help> run diagnostics. On the box that comes up, check the last two things. Click next and it should identify your iPod.
    2. Click on your windows start menu. Type in "services". Click on it and when it pops up, on the bottom of it click on "standard". Now Scroll down to find "Apple Mobile Device" Right click it when you see it and click on "Start". When it has started, close iTunes and replug in your iPod and it should show up.
    3. Check the USB cable
    4. Verify that Apple Mobile Device Support is installed
    5. Restart the Apple Mobile Device Service and verify that the Apple Mobile Device USB Driver is installed.
    6. If you just want to add some photos, songs and movies from computer to your devices, you can use an iTunes alternative to do the job.
    7. Check for third-party software conflicts.

  • Can someone tell me how to fix this error in 10.4.11 on a G5 Quad Core 2.5GHz Tower...A valid video device could not be found for playback. [-70017]

    Can someone tell me how to fix this error in 10.4.11 on a G5 Quad Core 2.5GHz Tower...A valid video device could not be found for playback. [-70017]

    That's an error reported from DVD Player I believe...
    kDVDErrorMissingGraphicsDevice = -70017, // A valid graphics device is not available.
    There's some conjecture it has to do with HDCP, or Video Card problems, but the only 2 cures/fixes I found were Software related, one was cured by updating the OS, another by replacing the Video kexts.
    I think this error also shows up if trying to use DVD player in Safe Mode, (too much research isn't good! ).
    At the Apple Icon at top left>About this Mac.
    Then click on More Info>Hardware>Graphics/Displays and report like this...
    NVIDIA GeForce 7800GT:
      Chipset Model:          GeForce 7800GT
      Type:          Display
      Bus:          PCI
      Slot:          SLOT-1
      VRAM (Total):          256 MB
      Vendor:          nVIDIA (0x10de)
      Device ID:          0x0092
      Revision ID:          0x00a1
      ROM Revision:          2152.2
      Displays:
    VGA Display:
      Resolution:          1920 x 1080 @ 60 Hz
      Depth:          32-bit Color
      Core Image:          Supported
      Main Display:          Yes
      Mirror:          Off
      Online:          Yes
      Quartz Extreme:          Supported
    Display:
      Status:          No display connected
    Can't think of much to try at the moment, but perhaps reapplying the big 10.4.11 combo, Repair Permissions, & reboot would help, not sure.
    The combo update for PowerPC-based Macs...
    http://www.apple.com/support/downloads/macosx10411comboupdateppc.html

  • I don't know what I did, but Aperture no longer sees my HD as online, and I can't get my photo versions since the HD is not online. I see it in Finder, but Aperture no longer recognizes it. Does someone know how to fix this?

    I don't know what I did, but Aperture no longer sees my HD as online, and I can't get my photo versions since the HD is not online. I see it in Finder and can see the original files and even copy them from Finder, but Aperture no longer recognizes the HD, and when I try to work with the picture, it doesn't let me because it says that the master is in a volume that's offline. Does someone know how to fix this?

    Just to clarify:
    Does Aperture not see the drive at all (that is, does Aperture also not see the drive in the import and export dialogue) or are only the Master Files disconnected?
    If Aperture does not recognize the drive at all, check the permission settings of the drive in the "Get Info" panel and make sure you have read/write access, also the "Ignore ownership on this volumn" checkmark, this should be set.
    If correcting the permissions does not help, make sure you have a backup, and then use "Disk Utility" to run a check and to repair the volumn, if necessary.
    If Aperture can see the drive on import and export, but only does not see the master image files, then try to reconnect your masters.
    Create a smart album or use a Search with the rule: "File status: offline", to select all images that need reconnecting to their masters.
    Right click on the first image of the selection.
    From the Pop-up window select "Locate referenced Files..."
    Now the "Reconnect All" button should appear.
    Click it.

  • Could not be moved to the mailbox (null) alert - anyone know how to fix this?

    Greetings
    When I archive mails in one of my mail accounts, about 50% of the time, I'll get an alert that says - "The message XYZ could not be moved to the mailbox (null) - The destination mailbox does not exist."
    Anyone know how to fix this?
    Thanks,
    John

    Can't Delete Mail Messages

  • When i try to update my itunes on my pc i keep getting the messaage that there was a problem with the installer and it could not finish. how do i fix this? i`ve tried to download 3 times already.

    when i try to update my itunes on my pc i keep getting the messaage that there was a problem with the installer and it could not finish. how do i fix this? i`ve tried to download 3 times already.

    Hi
    I've got a similar problem.  iTunes v10.2 worked fine, but when I tried to update it to 10.5 I got a 'Bonjour' error.  I eventually solved that but I still couldn't upgrade to 10.5, so I deleted every single Apple, Quicktime, iTunes, etc file on my PC using Revo Unistaller (because the normal Windows Add/Delete programs wouldn't work) but now, when I install the latest iTunes version from scratch (on XP SP3), it says: "the installer encountered errors before it could be configured.... your system has not been modified" 
    Any ideas?
    Rick

  • The song _____could not be used because the orignial file could not be found. anybody know how to fix this in windows?

    The song____could not be used, because the original file could not be found. Anybody know how to fix this in windows os?

    I am getting this same message.  I recently bought a new Macbook Pro and the geeks transferred my files from my mini-mac.  Perhaps they did not transfer something critical?  I follow the "locate" option when it asks to find my files and I get a file folder that has a red circle with a white bar in the middle. 
    I have the same issues with my downloaded movies but my apps all seem to be fine.
    Even more confusing - it seems to allow random songs to play and download on my Macbook and other devices.  But most of my music - whether downloaded from iTunes or my CD collection comes up with that message about the original file. 
    Should I get new geeks to locate these files on my old mini-mac?

  • When ever I try to export to Perfect Effects 8 a DNG Photo this is the Error message "Unable to complete the export. One or more files could not be found" Any one know how to fix this?

    When ever I try to export to Perfect Effects 8 a DNG Photo this is the Error message "Unable to complete the export. One or more files could not be found" Any one know how to fix this?@

    Adobe web chat come up with a solution.
    Open the PP project.
    Export your sequence or project as a Final Cut Pro XML file.
    Set up a new PP project.
    Import the Final Cut Pro XML file.
    This will get you back up an running.
    Since getting back to editing this project I have found that some things will be lost or change in using XML:
    You will lose position key framing, black video clips, dissolve fx, audio levels, audio dynamic fx, the ability to open a multi camera clip and change the camera view.
    You will keep cut points, crop fx.
    Not perfect but only took a couple of hours to save 3 days work.

  • My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    Hello there philp_69,
    If I understand correctly it sounds like your phone hasnt been recognized in iTunes on your PC since the last couple of updates. I would use the troubleshooting in the following article which will walk you through the steps one by one. 
    iPhone, iPad, or iPod touch not recognized in iTunes for Windows
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • When I try to download the latest version of iTunes on my iPod Classic I get the message that "iTunes has an invalid signature" and that "Content was blocked because it was not signed by a valid security certificate.  Anyone know how to fix this?

    When I try to download the latest version of iTunes from apple.com, I get the message "Content was blocked because it was not signed by a valid security certificate."When I open iTunes and try to download the latest version there, I get the message "iTunes has an invalid signature.  The download has been removed."  I have also gotten an Internet Script Error stating that an error has occured in Line 0, Char O and that "Access is denied to images.apple.com/global/scripts/lib/iepngfix.htc."  This problem has never occurred with earlier versions of ITunes.  Anyone know how to fix this problem? 

    Are you downloading iTunes form an Apple website or somewhere else? If the answer is somewhere else, try downloading it from Apple. Click on iTunes in the black menu bar above and go from there.
    Let us know what happens.

  • My ipad is not being recognized by the new iTunes update that just came  out about a week ago it worked fine till the update I have windows 8.1 does anyone know how to fix this problem and I just bought my ipad mini about a month ago

    My ipad mini is not being recognized by the new iTunes update that just came  out about a week ago it worked fine till the update I have windows 8.1 does anyone know how to fix this problem and I just bought my ipad mini

    I found this is another thread - same issue.
    Re: iTunes has stopped working. Why? 
    Sep 11, 2013 6:07 AM (in response to thurdy)
    Resolved!
    After contacting Apple, I received a reply from their engineers:
    Copy QTMovieWin.dll from:  C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    to: C:\Program Files (x86)\iTunes
    And that did the trick.
    Message was edited by: Stryder777

Maybe you are looking for

  • DO NOT BUY HP LASERJET ALL IN ONE PRINTERS

    just sent the following letter to the CEO as a final attempt. Dont know what else to do Dear Mr Hurd, I hope you will read through my email as I am a very frustrated hp customer. I bought a HP laserject 1522nf printer a few months ago it worked fine

  • Nokias have some problems.

    I own a Nokia Lumia 928. Things have been going well with it. I've had some problems though. Such as my screen freezing resulting me into rebooting my phone. Another problem that really bugs me is that my phone's screen has permanently turned pink. I

  • JavaFX 2 in zip format?

    Is there anyway of getting JavaFX in a zip format instead of an actual installer for windows os? Thanks. Edited by: 998341 on Apr 5, 2013 11:51 AM

  • Personalize link not appearing in Portal

    Hello Gurus We had installed EP 7.0 sometime back but I have observed today that the poersonalize link is not appearing for a user that I created. Can someone please tell me how to correct this? Thanks.

  • Photoshop and XSAN

    Hi, I can not save image from Photoshop CS5 and CS6 to XSAN 3 disk (both client and server are updated to latest versions) I get "Could not save "filename.psd" because of a disk error. File permissions are OK All other Adobe applications are saving j