Reputation: 1137
Good day.
Today i was trying to practice python and Im trying to make a script that reads the lines from a file containing only numbers and using said numbers as a parameter in another Python script.
Here at work i sometimes need to execute a python script called Suspend.py, ever time i excute this scripit i must type the following information:
Suspend.py suspend telefoneNumber
I have to do this procedure many times during the day and i have to do this for every number on the list, it is usually a very long list. SO i though on trying to make things a little bit faster and creat a Python script myself.
Thing is a just started learning Python on my own i kinda suck at it, so i have no idea on how to do this.
In one file i have the following numbers:
87475899
87727856
87781681
87794922
87824499
88063188
88179211
88196532
88244043
88280924
88319531
88421427
88491113
I want python to be able to read line by line and send this number to another file script together with the word "suspend" on the previously said python script.
Upvotes: 1
Views: 60
Reputation: 27273
If I understand you correctly:
import subprocess
with open("file_with_numbers.txt") as f:
for line in f:
subprocess.call(["python", "Suspend.py", "suspend", line.strip()])
Upvotes: 2