0

I have a python script but I am not sure how I can use it. The script looks like this

def usage():
    print "usage : ./ssl-patch <apk file>"

def unzip_apk(infile, output):
    zfile = zipfile.ZipFile(infile, 'r')
    zfile.extractall(output)
    zfile.close()

def zip_to_apk(indir, output):
    outapk = zipfile.ZipFile(output, 'w')
    for (path, dirs, files) in os.walk(indir):
        zipath = path[len("./" + output):]
        for filename in files:
            outapk.write(os.path.join(path, filename), os.path.join(zipath, filename), zipfile.ZIP_DEFLATED)
    outapk.close()

def escape_dollar(string):
    return(re.sub('\$','\\$',string))

I put all the files in one folder then located to it with cd and then wrote nameOfScript.py fileName.apk I have also tried many other ways to write it but cant figure it out.

but I get the error

print "usage : ./ssl-path <apk file>"                                        ^
SyntaxError: invalid syntax

Thanks :)

laalto
  • 150,114
  • 66
  • 286
  • 303
user2880751
  • 23
  • 2
  • 7
  • are you trying to run this on an Android device? – FoamyGuy Oct 15 '13 at 23:47
  • 2
    This is a Python 2 script. If you're using Python 3, then the `print` statement would indeed raise `SyntaxError`. What's the output of running `python -V`? – Tim Peters Oct 15 '13 at 23:49
  • 2
    This is not your entire script. There is nothing in the code you've shown that calls `usage`, so whatever is wrong is in the part you haven't shown us. – abarnert Oct 15 '13 at 23:49
  • 1
    @abarnert, it's a compile-time syntax error, on the `print` statement in the `usage()` function. – Tim Peters Oct 15 '13 at 23:50

1 Answers1

0

Welcome to SO.

The script lacks a main section, it only consists of function definitions (starting with def).

A script that includes a main part (either using if __name__ == '__main__': or just having statements outside of function definitions) can be invoked with python [name_of_script] [command-line-parameters].

Hope that helps :)

Markus M.
  • 1,182
  • 2
  • 8
  • 17