Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-24-2015, 05:50 AM
|
#1
|
LQ Newbie
Registered: Dec 2003
Posts: 12
Rep:
|
Shell script to cause wifi scan get "unexpected end of file" message
I need to get my wifi scanning while I run Wireshark in Ubuntu. I tried some of the scripts that I found on the internet, but they did not run correctly. So, I decided to write my own very simple script. I know there are more elegant ways to do this, but I decided to keep things as simple as possible, after verifying that if I enter, for example, sudo iwconfig wlan0 channel 1 that the wifi modem tunes to channel 1. So, what I want to do is to continuously scan through the a and b channels while running Wireshark. I want it to dwell on each channel for 0.1 seconds. But, every time I try to run this shell script, I get an "unexpected end of file" error. What is wrong? I suspect it is something simple and stupid, but I can't spot it.
#!/bin/bash
while true
do
iwconfig mon0 channel 1
sleep .1
iwconfig mon0 channel 2
sleep .1
iwconfig mon0 channel 3
sleep .1
iwconfig mon0 channel 4
sleep .1
iwconfig mon0 channel 5
sleep .1
iwconfig mon0 channel 6
sleep .1
iwconfig mon0 channel 7
sleep .1
iwconfig mon0 channel 8
sleep .1
iwconfig mon0 channel 9
sleep .1
iwconfig mon0 channel 10
sleep .1
iwconfig mon0 channel 11
sleep .1
iwconfig mon0 channel 36
sleep .1
iwconfig mon0 channel 40
sleep .1
iwconfig mon0 channel 44
sleep .1
iwconfig mon0 channel 48
sleep .1
iwconfig mon0 channel 52
sleep .1
iwconfig mon0 channel 56
sleep .1
iwconfig mon0 channel 60
sleep .1
iwconfig mon0 channel 64
sleep .1
iwconfig mon0 channel 149
sleep .1
iwconfig mon0 channel 153
sleep .1
iwconfig mon0 channel 157
sleep .1
iwconfig mon0 channel 161
sleep .1
done
|
|
|
11-24-2015, 05:58 AM
|
#2
|
Senior Member
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,219
|
Nothing wrong with the bash syntax, maybe you have odd hidden characters? did you use a windows text editor to make the script if so you will have windows style line endings which would produce that or a similar error
|
|
|
11-24-2015, 06:08 AM
|
#3
|
LQ Newbie
Registered: Dec 2003
Posts: 12
Original Poster
Rep:
|
I did use the windows text editor to create the script, although I did some modifications in Gedit. How do I find and eliminate the extra characters? As I said, latest version edited and saved with Gedit.
|
|
|
11-24-2015, 07:19 AM
|
#4
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,250
|
usually that means \r\n at the end of line which may cause such kind of errors.
use od -xv filename for example to check it
|
|
|
11-24-2015, 07:25 AM
|
#5
|
LQ Newbie
Registered: Dec 2003
Posts: 12
Original Poster
Rep:
|
Thanks. That was the problem. I ran dos2unix on the file and it works now.
|
|
|
11-27-2015, 09:39 AM
|
#6
|
Member
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207
Rep: 
|
> I tried some of the scripts that I found on the internet, but they did not run correctly.
why not? i'm sure the authors hoped what they spent time writing and releasing could be used by others.
so you tried several and they were damaged? very bad. please say what you think the cause of damage is!
|
|
|
All times are GMT -5. The time now is 12:21 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|