'Terminal Concentrate Program's output to string? [closed]
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.
Solution 1:[1]
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.
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 0x263A |
| Solution 2 | Avinash |
