Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > While-Read problem

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 2 Weeks Ago   #1 (permalink)
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.
jgardner is offline  


Reply With Quote
Old 2 Weeks Ago   #2 (permalink)
Linux Newbie
 
Join Date: May 2008
Location: NYC, moved from KS & MO
Posts: 247
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?
secondmouse is offline   Reply With Quote
Old 2 Weeks Ago   #3 (permalink)
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!
jgardner is offline   Reply With Quote
Old 2 Weeks Ago   #4 (permalink)
Linux Newbie
 
Join Date: May 2008
Location: NYC, moved from KS & MO
Posts: 247
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.
secondmouse is offline   Reply With Quote
Old 1 Week Ago   #5 (permalink)
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!
jgardner is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:53 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2