[SOLVED] Shell script to cause wifi scan get "unexpected end of file" message
Linux - SoftwareThis 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.
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.
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
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 3,070
Rep:
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.