0

I'm running Kali Linux and need to pull off a load of commands, but I'm making a script to really speed that up for me. Here is the .py file:

import os

if raw_input("Begin fake Access Point? (y/n): ")=="y":
 os.system(airmon-ng)

interface = input("Enter your Interface name: ")
 os.system(airmon-ng "interface" start)

I'm getting this error when trying to run it:

  File "WNS.py", line 7
    os.system(airmon-ng "interface" start)
    ^
IndentationError: unexpected indent

Tried to remove the whitespace in the beginning but then I just get this error:

IndentationError: expected an indented block

14
  • 1
    You have a space at the begging of that line, you need to to be lined up with the line above it. Commented Nov 12, 2015 at 17:51
  • Yeah I do that then I get this error: "IndentationError: expected an indented block" Commented Nov 12, 2015 at 17:52
  • But only remove it before the second one, not the first since that one is inside the if block (i.e. exactly as indicated by the error message). Commented Nov 12, 2015 at 17:53
  • 1
    Pro tip: set your editor to indent 4 spaces when you hit the TAB key. With 4 spaces it becomes obvious what is properly indented. Your first os.system() line should really use 4 spaces, not one. Your last should not be indented, it is not part of an if block. Commented Nov 12, 2015 at 17:53
  • 1
    Next issue: don't use os.system(), the subprocess module is a much better tool for running external scripts. Commented Nov 12, 2015 at 18:02

1 Answer 1

3

Indendation is very important in Python. It is used by the interpreter to know how to delimit blocks of instructions.The parameters to the os.system() call don't look good either. Anyway this is how it's supposed to look like

import os

if raw_input("Begin fake Access Point? (y/n): ")=="y":
    os.system("airmon-ng")

interface = input("Enter your Interface name: ")
os.system("airmon-ng "+interface+" start")
Sign up to request clarification or add additional context in comments.

3 Comments

Okay yes that works but you said my os.system() doesn't look good? How should I sort those out?
4 space indentations. anything following an : character should be four spaces (or 1 tab) indented from its above line
@Busturdust: Python expand tabs to the next 8th position. New code should avoid using tabs.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.