Linked Questions
181 questions linked to/from Running Bash commands in Python
175
votes
11
answers
528k
views
Python Script execute commands in Terminal [duplicate]
I read this somewhere a while ago but cant seem to find it. I am trying to find a command that will execute commands in the terminal and then output the result.
For example: the script will be:
...
24
votes
3
answers
101k
views
How to run bash commands inside of a Python script [duplicate]
I am trying to run both Python and bash commands in a bash script.
In the bash script, I want to execute some bash commands enclosed by a Python loop:
#!/bin/bash
python << END
for i in range(...
15
votes
1
answer
41k
views
Execute Bash commands Python way [duplicate]
I am currently executing bash commands manually, by entering in shell in the python code.
How would one do this in the pythonic way?
i am currently using os.system function to execute commands like;
...
0
votes
2
answers
8k
views
Running bash command in python [duplicate]
I'm trying to run a long bash command with several pipes inside. I did some research and found the use of os.chdir() to change to a working directory, and subprocess to execute bash commands.
First I ...
3
votes
1
answer
4k
views
Running bash commands in Python: os vs subprocess? [duplicate]
I read this question in which the asker is having a specific problem with running bash in Python using code like this:
os.system(bashCommand)
The top two answers simply say: "use subprocess" (instead ...
1
vote
2
answers
1k
views
run linux wget command using python [duplicate]
So using my linux terminal, I can run a command to download all pdfs from a website
wget -A pdf -m -p -E -k -K -np http://site/path/
but I want to automate the process. For example run the command ...
-1
votes
2
answers
601
views
How to run bash command in Python script? [duplicate]
I want to convert some PDF file to TXT file in a bash script.
pdf2txt.py -o otuput.txt input.pdf
this is the command to do the task for a single file.
But for large set of file I am trying to do the ...
0
votes
1
answer
848
views
how to run bash inside python loop [duplicate]
I have two files as below and I want to loop over the two files to create different combinations based on line in each file then input them as i and j to bash script in python:
file1
aaaa
tttt
cccc
...
0
votes
0
answers
441
views
Capture subprocess call stdout/stderr [duplicate]
I am creating a simple web server with Flask which will receive the request, do some processing and kick off a Terraform to build some resources in the cloud.
Not sure if this is the best way but I've ...
0
votes
1
answer
373
views
Executing Shell commands using python In Linux [duplicate]
So I just recently started having interest and playing CTF's on OverTheWire website and I am still in the first challenge called the bandit Lvl5 if you'll consider looking at it. So it teaches the use ...
0
votes
1
answer
253
views
how do I make a button in Tkinter that runs a shell command [duplicate]
I am trying to make a button the command: print("test"). Here is what I have so far:
import os
root = tk.Tk()
button = tk.Button(text="print",
fg="black&...
0
votes
0
answers
218
views
Get logs of bash code from bash subprocess [duplicate]
I'm running some bash codes from python using subprocess module, E.G.
import subprocess
container_logs = 'az container logs --name textgeneratorinference'
subprocess.call([container_logs],shell=True)...
1
vote
0
answers
141
views
error with turning a bash (with * and pipes) command into Popen [duplicate]
I have this bash script I want to call directly from Python:
#!/bin/bash
for usb in $(ls /dev/ttyUSB*); do echo $(udevadm info $usb | grep ID_SERIAL= | cut -d ' ' -f 2) $usb; done
I'm getting error ...
-2
votes
1
answer
143
views
How do I process output from the command line into python? [duplicate]
So I found this tool: https://github.com/elceef/dnstwist and I want to pass a list of domains into that tool then take the output and visualize it.
It operates through the command line, but how do I ...
0
votes
1
answer
79
views
Running bash script with python [duplicate]
I wrote python script to run bash script it runs it with this line:
result = subprocess.Popen(['./test.sh %s %s %s' %(input_file, output_file, master_name)], shell = True)
if result != 0:
print("...