subprocess Questions

66

Solved

How do I call an external command within Python as if I had typed it in a shell or command prompt?
Outrigger asked 18/9, 2008 at 1:35

6

Solved

In the process of using the ffmpeg module to edit video files i used the subprocess module The code is as follows: #trim bit import subprocess import os seconds = "4" mypath=os.path.abspath('tr...
Jd asked 16/7, 2017 at 17:29

2

I am using the subprocess module to run binaries from python. To capture the output produced by the binary, I am using: proc = subprocess.Popen (command_args, shell=False, stdout=subprocess.PIPE)...
Argillaceous asked 19/5, 2011 at 17:15

6

Solved

I want to run the following bash command in Python 3: ls -l I know that I can do the following: from subprocess import call call(['ls', '-l']) How do I save this output to a file, or put it i...
Observe asked 16/1, 2012 at 13:8

4

Is there a way of passing some runas=True arg to a subprocess.run function in python? I want to run a process as admin (elevate it). Thanks for answers :)\ EDIT: Using Windows OS.
Yasmineyasu asked 19/11, 2017 at 18:23

4

Solved

I get couple of grep:write errors when I run this code. What am I missing? This is only part of it: while d <= datetime.datetime(year, month, daysInMonth[month]): day = d.strftime("%Y%m%d")...
Routinize asked 31/3, 2013 at 3:21

3

Solved

Using subprocess and the command 'gnome-terminal -e bash' I can open up a gnome-terminal as desired (and have it stick around). This is done with either p=subprocess.Popen(['gnome-terminal', '-e',...
Gametophore asked 7/1, 2016 at 15:49

4

Solved

When I run in my Ubuntu terminal: sudo dd if=/dev/sda of=~/file bs=8k count=200k; rm -f ~/file it works fine. If I run it through Pythons subprocess.Popen(): output, err = subprocess.Popen(['s...
Snatch asked 17/11, 2016 at 18:51

2

I have an Apache web server and I made a python script to run a command. Command that I'm running is launching a ROS launch file, that is working indefinitely. I would like to read output from the ...
Seventeenth asked 4/5, 2015 at 8:47

3

I'm trying to search a text file and retrieve lines containing a specific set of words. This is the code I'm using: tyrs = subprocess.check_output('grep "^A" %s | grep TYR' % pocket_location, shel...
Tine asked 7/1, 2014 at 22:41

6

Solved

I need to run the command date | grep -o -w '"+tz+"'' | wc -w using Python on my localhost. I am using subprocess module for the same and using the check_output method as I need to capture the outp...
Sian asked 19/6, 2014 at 12:5

3

Solved

Using Python 3.4.3 on Windows. My script runs a little java program in console, and should get the ouput: import subprocess p1 = subprocess.Popen([ ... ], stdout=subprocess.PIPE, stderr=subproces...
They asked 22/10, 2015 at 14:33

2

I'm running an SSH process like this: sshproc = subprocess.Popen([command], shell=True) exit = os.waitpid(sshproc.pid, 0)[1] This works and opens an interactive terminal. Based on the documentat...
Commitment asked 16/9, 2010 at 17:56

5

Solved

My program in tkinter is working well when I am running it using PyCharm, when I am creating .exe file using pyinstaller,pyinstaller -i"icon.ico" -w -F script.pyI have no errors. I am pasting scri...
Spearwort asked 22/5, 2018 at 8:35

1

I'm using asyncio subprocess to execute a subcommand. I want to see the long-running process and save the content at the same time to a buffer for later use. Furthermore, I found this related quest...
Copyholder asked 18/1, 2022 at 17:11

4

Solved

Problem: Use the PSQL pg_dump and pg_restore in a Python script and using the subprocess module. Background: I am using the following python 2.7 script from the localhost (i.e. Ubuntu 14.04.5 LTS)...
Liston asked 12/4, 2017 at 21:54

10

Solved

I need to debug a child process spawned by multiprocessing.Process(). The pdb degugger seems to be unaware of forking and unable to attach to already running processes. Are there any smarter pytho...
Koph asked 17/1, 2011 at 18:32

5

Solved

I'm using the subprocess.Popen call, and in another question I found out that I had been misunderstanding how Python was generating arguments for the command line. My Question Is there a way to f...
Adest asked 12/2, 2013 at 16:19

14

Solved

I'm trying to write a small script to mount a VirtualBox shared folder each time I execute the script. I want to do it with Python, because I'm trying to learn it for scripting. The problem is tha...
Endocranium asked 24/10, 2012 at 8:37

5

I know how to run a command using cmd = subprocess.Popen and then subprocess.communicate. Most of the time I use a string tokenized with shlex.split as 'argv' argument for Popen. Example with "ls -...
Lysozyme asked 12/9, 2011 at 14:43

6

I'm running this: os.system("/etc/init.d/apache2 restart") It restarts the webserver, as it should. However, it also outputs a message like so (like it would if I had run the command dir...
Glinys asked 8/4, 2011 at 14:55

1

Solved

Backround I am calling an executable from Python and need to pass a variable to the executable. The executable however expects a file and does not read from stdin. I circumvented that problem previ...
Gannes asked 7/1, 2022 at 16:36

3

The bash code is: mx=8;my=8;head -c "$((3*mx*my))" /dev/urandom | convert -depth 8 -size "${mx}x${my}" RGB:- /tmp/random.png And the code in python3: #!/usr/bin/python3 import subprocess resu...
Scramble asked 4/6, 2018 at 14:7

17

Solved

To launch programs from my Python-scripts, I'm using the following method: def execute(command): process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) ...
Whitney asked 11/12, 2010 at 16:3

3

is there a way to call a program from python without waiting for it to return? i created a script which copies a program to a directory and runs that program. but when i call the program from pytho...
Brierwood asked 8/4, 2010 at 17:23

© 2022 - 2024 — McMap. All rights reserved.