Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all...so I'm making this script that will run through a file (each ssid on it's own list, with spaces in it) and running a program. Problem is, as I ...
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    3

    While-Read problem



    Hi all...so I'm making this script that will run through a file (each ssid on it's own list, with spaces in it) and running a program. Problem is, as I tested with echo, anything I put after the $line is basically going to the beginning and overwriting. Here's my code:

    Code:
    #!/bin/bash
    cat ssid-space |
    while read list
    do
    genpmk -f worldlist -d \"${list}\" -s \"${list}\"
    done
    If I placed an echo in front of genpmk to see what it's trying to do...while you can see here:
    Code:
    " -s "Wireless Network "Wireless Network
    " -s "Philips WiFit -d "Philips WiFi
    " -s "Customer IDst -d "Customer ID
    " -s "Home Networkt -d "Home Network
    " -s "Harvard UniversityHarvard University
    " -s "My Wireless Network AWireless Network A
    " -s "Intel Gateway -d "Intel Gateway
    " -s "IU Wirelessst -d "IU Wireless
    " -s "Verizon Wi-Fi -d "Verizon Wi-Fi
    " -s "<any ssid>ist -d "<any ssid>
    " -s "home wireless -d "home wireless
    It is much appreciated.

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    Can you show some sample of the file ssid-space? Also help us understand what exactly you are trying to achieve - what should a NORMAL/CORRECT line look like in the while loop?

  3. #3
    Just Joined!
    Join Date
    Nov 2009
    Posts
    3
    So sorry, should have thought about that in the beginning.

    The ssid-space file contains:
    Code:
    Wireless Network
    Philips WiFi
    Customer ID
    Home Network
    Harvard University
    My Wireless Network A
    Intel Gateway
    IU Wireless
    Verizon Wi-Fi
    <any ssid>
    home wireless
    My Network
    The genpmk for the first genpmk command should therefore look like this:

    Code:
    genpmk -f wordlist -d "Wireless Network.hash" -s "Wireless Network"
    Thanks!

  4. #4
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    It would be much easier with awk for this kind of task:
    Code:
    awk '!/^$/{print "genpmk -f wordlist -d \42"$0".hash\42 -s \42"$0"\42"}' ssid-space|sh
    !/^$/ is used to prevent empty lines being printed (just in case you have empty lines in ssid-space. \42 is the double quotation mark.

  5. #5
    Just Joined!
    Join Date
    Nov 2009
    Posts
    3
    So, it turns out that the ssid file itself was the culprit. It was made in windows so it had the carriage return \r at the end of the lines. This was causing the issue. I'm not sure if my original code would have worked or not, but secondmouse's worked beautifully after I took out the carriage returns. Thank you so much for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •