Python + bash
Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете?
Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно.
Советую обратить своё внимание на очень крутую библиотеку sh.
Что она умеет?
🔸 удобный синтаксис вызова команд как функций
# os
import os
os.system("tar cvf demo.tar ~/")
# subprocess
import subprocess
subprocess.call(['tar', 'cvf', 'demo.tar', '~/'])
# sh
import sh
sh.tar('cvf', 'demo.tar', "~/")
🔸 простое создание функции-алиаса для длинной команды
fn = sh.lsof.bake('-i', '-P', '-n')
output = sh.grep(fn(), 'LISTEN')
в этом примере также задействован пайпинг
🔸 удобный вызов команд от sudo
with sh.contrib.sudo:
print(ls("/root"))
Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера.
А вот вариант с вводом пароля через код.
password = "secret"
sudo = sh.sudo.bake("-S", _in=password+"\n")
print(sudo.ls("/root"))
Это не все фишки. Больше интересных примеров смотрите в документации.
Специально для Windows💀 юзеров
#libs#linux
☑️☑️Below you will see the Futures Premium Signals Results for (09th April 2026)
🚀#AIA-USDT - 111% profit
🚀#4-USDT - 154% profit
✅✅Net Profit = 264% Profit
👇🏻Signals Summary
➕Total Signals Sent out - 02
✔️Profitable Signals - 02
✖️Total Signals Lost - 00
◼️Trade cancelled without being executed - 00
✅✅Net Profit - 264% Profit
👁🗨Contact @futurechief to enter the most profitable Futures Premium Signal Group
🎯🎯 Non Stop Huge profit on Premium signals for all Premium Members
🔥🔥#AIA/USDT has crossed all the profit targets and made a great profit of 111%
👁🗨Contact @futurechief to enter the Premium Futures & SPOT Group for daily gains
🚀🚀Raining Profits in the Premium Group
🎯🎯#AIA/USDT has covered all the targets to give an amazing profit of 70% for all Premium Members
👁🗨Contact @futurechief to enter the premium group & make daily gains on Futures as well as Spot Market
🚀🚀🚀160%+ Huge Profit on #AIA/USDT as it has hit all the profit target with great easiness - The trade has been closed today
👁🗨Contact @primemod to enter the premium group & make daily gains
✅✅ 53% Profit on #AIA/USDT for our Premium Members on Futures, OKX, Bybit, Kucoin
🔥🔥 All target completed
👁🗨Contact @primemod to enter the Premium Binance Futures/Bybit/Kucoin/OKX & SPOT Group for daily gains