user3821329
user3821329

Reputation: 317

passing the filename to a python script in command line

I want to pass the name of a file to a python script while I'm running it from the command line. I'm trying this clear command:

cat enwiki-latest-pages-articles.xml | python WikiExtractor.py -b 500K -o extracted

however, it gives an error:

'cat' is not recognized as an internal or external command, operable program or batch file.

Thanks in advance.

Upvotes: 1

Views: 1090

Answers (2)

falsetru
falsetru

Reputation: 369064

It seems like you're running the command in Windows. In windows, there's no cat installed unless you installed.

You can use type command instead:

type enwiki-latest-pages-articles.xml | python WikiExtractor.py -b 500K -o extracted

Upvotes: 2

castor
castor

Reputation: 583

The correct way would be python WikiExtractor.py -b5 -o extracted -f enwiki-latest-pages-articles.xml.

And use sys.argv array of input arguments of python command from sys command. This may help: http://www.tutorialspoint.com/python/python_command_line_arguments.htm

Upvotes: 2

Related Questions