Roughly three years have passed and this relatively simple question still lacks a proper answer. Encountering the same issue today using IDA 7.0, I might as well spend the time providing a proper answer.
Quoting from IDA's help file
Execute a script file when the database is opened.
The script file extension is used to determine which extlang will run the script.
It is possible to pass command line arguments after the script name.
-S"myscript.idc argument1 \"argument 2\" argument3"
The passed parameters are stored in the
ARGV global IDC variable. Use
ARGV.count to determine the number of arguments. The first argument
ARGV contains the script name
The documentation quoted above provides an explicit example for the IDC scripting language but leaves us to interpolate / guess what would be the IDAPython equivalent.
Naturally, one might assume idc's
ARGV parameter will be translated to python's well known
sys.argv, which is used precisely for that in most python files as is well-documented to hold the command line arguments provided when a script is run.
The name resemblance fooled me too, however because of how python scripts are executed in IDA the documentation above should be treated literally in python as well. The
ARGV is the only place arguments are accessible to IDA python scrips executed using the
In IDA python, however, it is not available as a global paramter but should be accessed through the
Here's a simple example;
given the followingf
import sys, idc
print("Sys args: " + str(sys.argv))
print("Idc args: " + str(idc.ARGV))
Executing the following command (ignoring the usual IDA banner):
ida64 -A -S"myscript.py" arg1 "arg one and a half" arg2 -L/some/other/flags/logfile.txt -t
Will result in the following output:
Sys args: 
Idc args: ["arg1", "arg one and a half", "arg2"]