Home > database >  Terminal Concentrate Program's output to string?
Terminal Concentrate Program's output to string?

Time:05-10

In terminal I used to run:

wget https://chromedriver.storage.googleapis.com/101.0.4951.41/chromedriver_linux64.zip

suppose I have a python script called test.py which outputs version number, how can I insert that version inside the above url to replace 101.0.4951.41

My try was to write this:

wget https://chromedriver.storage.googleapis.com/ 'python3 test.py' /chromedriver_linux64.zip

I would prefer a 1 like solution.

CodePudding user response:

You can redirect the output of test.py into your url following this pattern:

echo 101.0.4951.41 | (read var; wget https://chromedriver.storage.googleapis.com/$var/chromedriver_linux64.zip)

Outputs:

*file download logs*

Simply replace echo 101.0.4951.41 with python3 test.py.

CodePudding user response:

You can actually run your command from the test.py itself:

import os
version = "101.0.4951.41"
os.system(f"wget https://chromedriver.storage.googleapis.com/{version}/chromedriver_linux64.zip")

Then run it like: python test.py

  • Related