You need to specify the script.ipy file. When it ends in .ipy, it may contain ipython syntax.
From ipython --help :
Usage ipython [subcommand] [options] [files] If invoked with no options, it executes all the files listed in sequence and exits, use -i to enter interactive mode after running the files. Files ending in .py will be treated as normal Python, but files ending in .ipy can contain special IPython syntax (magic commands, shell expansions, etc.)
source share