Linked Questions

10 votes
6 answers
60k views

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 into ...
beoliver's user avatar
  • 5,769
15 votes
4 answers
38k views

Everytime I'm executing my Python script, it appears to hang on this line: lines = sys.stdin.readlines() What should I do to fix/avoid this? EDIT Here's what I'm doing with lines: lines = sys....
Bo A's user avatar
  • 3,154
14 votes
3 answers
18k views

I need to run a program and gather its output to stdout. This program (socat) needs to run in the background for the duration of the python script. Socat sits in dameon mode once it's run, but first ...
Jason's user avatar
  • 143
16 votes
2 answers
25k views

I'm running a process with the use of Popen. I need to wait for the process to terminate. I'm checking that the process have terminated through the returncode. When returncode is different from None ...
user684322's user avatar
11 votes
6 answers
6k views

I wrote a simple python script for my application and predefined some fast commands like make etc. I've written a function for running system commands (linux): def runCommand(commandLine): print(...
Max Frai's user avatar
  • 64.6k
10 votes
3 answers
19k views

I am running a sub-program using subprocess.popen. When I start my Python program from the command window (cmd.exe), the program writes some info and dates in the window as the program evolves. When ...
8 votes
3 answers
17k views

I have noticed two different behaviors with two approaches that should have result in the same outcome. The goal - to execute an external program using subprocess module, send some data and read the ...
izac89's user avatar
  • 3,960
4 votes
5 answers
3k views

I'm on linux, and I have one python script that I want to call from another python script. I don't want to import it as a module (for a layer of security, and now for an academic exercise because I ...
Nathan's user avatar
  • 79.4k
0 votes
5 answers
8k views

I just found this great wget wrapper and I'd like to rewrite it as a python script using the subprocess module. However it turns out to be quite tricky giving me all sorts of errors. download() { ...
stratis's user avatar
  • 8,122
7 votes
1 answer
7k views

I'm using a pretty basic setup with subprocess.Popen() and directing stdout to a variable which I later return to a different part of my python script. Here is my basic Popen code: process = ...
calumb's user avatar
  • 1,061
0 votes
2 answers
8k views

I am using python sys to save my stdout to a text file. sys.stdout=open('OLSYield.txt','w') However I only want a portion of the stdout to go to the text. How do I stop writing to txt file and ...
galucero's user avatar
  • 353
4 votes
4 answers
5k views

I am using a python script to automate a process involving batch files. These are batch files that are used for other applications and I am not allowed to edit them. At the end of the batch file, it ...
Stoating's user avatar
  • 411
0 votes
3 answers
5k views

I have a shell script called "nn.sh" which takes an ip address in a local network and SSH into that ip and then continuously read off some data from that ip and appends the results to a file called "...
Mohsen Karimzadeh Kiskani's user avatar
3 votes
1 answer
4k views

I've read many of the questions related to this and learned a lot but I still haven't been able to solve my problem. I'm building a wxPython app that runs a c++ executable and displays the stdout from ...
anderspitman's user avatar
  • 10.8k
0 votes
2 answers
5k views

I am currently using python 2.7 and will need to ping windows and linux. I want to create a function that will return the IP address from a ping within a python script. I currently have this function ...
Wish I Knew this stuff's user avatar

15 30 50 per page