Using IDA 6.6, I cannot pass command line arguments to the IDAPython script.

The command I use is:

idaq64 -c -A -S"myscrip.py arg1" thebinpath. 

Here is the demo script myscript.py:

import sys
if len(sys.argv) >= 2:
    print("Successfully received parameters: " + str(sys.argv))
    print("Failed receiving parameters!!")

I obviously expect the python script to print the "Successfully received parameters" sentence with "arg1" as the only parameter, however "Failed receiving parameters!!" is printed instead.

For some unknown reason sys.argv has only one string (myscript.py).

I guess that there might be another way of getting these parameters, is this right?

  • I have had problems as well with arguments in IDAPython scripts. My recommendation, which is what I do and works, is to use environment variables, like: SOME_VAR=value idaq64 -A -S"script.py" binary Mar 10, 2015 at 8:40
  • 1
    Thank you for your reply. I later find another solution for this. The python arguments seems to be stored in the idc.ARGV. So I just use idc.ARGV to test the arguments.
    – William
    Aug 13, 2015 at 15:35

1 Answer 1


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.

For example: -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[0] 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 -S flag.

In IDA python, however, it is not available as a global paramter but should be accessed through the idc module.

Here's a simple example;

given the followingf myscript.py file:

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"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.