GK89
GK89

Reputation: 664

Have Python script read a text file instead of single input

I am working with this python script: https://github.com/sarchar/addressgen/blob/master/genaddress.py

Currently it works via command line like so:

python3 genaddress.py -p passphrase

How would I alter the script to accept a text file of passphrases?

Upvotes: 0

Views: 125

Answers (1)

Arnav Borborah
Arnav Borborah

Reputation: 11807

I know this might not directly answer the question (How would I alter the script), but it should achieve a similar result on bash with the following command, assuming each passphrase has its own unique output:

cat passphrases.txt | xargs -I phrase python3 genaddress.py -p phrase

This iterates through each line in passphrases.txt and then subsequently passes it to your script, one line at a time.

Upvotes: 4

Related Questions