Questions tagged [subprocess]

3

votes
1

answer
52

Views

Executing tensorflow python3 on remote server, subprocess can't interpret all of tensorflows input args. ImportError: No module named 'scripts'

I'm trying to execute tensorflow image identification on a remote server from my local host. My local machine has a script that runs this subprocess ssh command to execute the script on the remote server. stdoutdata = subprocess.getoutput('sshpass -p \'mypassword\' ssh [email protected] "python3 ../va...
Elliot Robert
1

votes
1

answer
2.6k

Views

How to terminate external program or window using python

I am trying to close the program, in this case spotify, but I am keep getting semantic mistake. Here is my code: sup_programs.txt { 'spotify': ['C:/Users/Daniiar/AppData/Roaming/Spotify/Spotify.exe'] } script: class Path(object): import ast sup_programs_txt = open('sup_programs.txt', 'r') s_p = sup...
Daniiar Abdiev
1

votes
1

answer
118

Views

apt-like progress in last line of terminal

I want to write a python script that displays its current progress in the last line of the terminal, similar to how apt (not apt-get) behaves. I know there are ANSI control sequences to interact with the terminal, but the issue is that I want to call other programs (using subprocess) which produce t...
Felix
-1

votes
0

answer
16

Views

how to get ubuntu machine id using python

I want the get the machine id from my system by using python code. My machine id is stored in "/var/lib/dbus/machine-id" . The machine id was "556b837c93cd4b8dbd3a1c01f468d9f5" How to get the number from the file and assign it to a variable using python. Any code suggestions..
Paul Steven
1

votes
1

answer
288

Views

sending message to subprocess with Ruby

Let's say I have a process started from a ruby script like so: pid = spawn('./my_awesome_process') Process.detach(pid) This process listens on STDIN. I now wish to read command line input, and send it to the process like so: puts "Please enter input" input = gets How do I then forwards input to my P...
Abraham P
1

votes
3

answer
1.8k

Views

subprocess.Popen process stdout returning empty?

I have this python code input() print('spam') saved as ex1.py in interactive shell >>>from subprocess import Popen ,PIPE >>>a=Popen(['python.exe','ex1.py'],stdout=PIPE,stdin=PIPE) >>> a.communicate() (b'', None) >>> why it is not printing the spam
user2728397
0

votes
0

answer
21

Views

Why does subprocess.run not read new lines yet subprocess.call does?

Why is it that calling an executable via subprocess.call gives different results to subprocess.run? The output of the call method is perfect - all new lines removed, formatting of the document is exactly right, '-' characters, bullets and tables are handled perfectly. Running exactly the same functi...
lawson
1

votes
2

answer
118

Views

How to call a php script in server from python

I am trying to run the php script which is in my server from the python project which is in my local machine. I have tried following till now Python Side: # -*- coding: utf-8 -*- import subprocess import json import sys import os def php(script_path): p = subprocess.Popen(['php', script_path], stdo...
user1687891
1

votes
1

answer
992

Views

Reusing subprocess object

I have a Python script that needs to issue a number of shell commands. I thought I could just create a subprocess object and then reuse it each time I had a command to execute. This is how I have my code set up: def setupPipeline(self): setupShell = subprocess.Popen([''], stdout=subprocess.PIPE, sh...
phileas fogg
1

votes
1

answer
630

Views

Python Queue suddenly empty

I'm trying to run a couple of calculations concurrently based on this example. I extended it in the way that instead of just a simple function, I'm running some external software via subprocess. It's run with Python 2.7.6 on Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86_64). There is a Queue i...
helm
1

votes
2

answer
460

Views

problems using python subprocess/sh as a bash wrapper

I'm trying to execute the following line of code: subprocess.call(["java", "-cp", "/home/me/somepath/file.jar", ..., "-someflag somevalue"]) The code fails and the jar I'm trying to run gives me usage information. But if I expand out the string and paste it into the terminal, it works (I know I'm ex...
anonymous
1

votes
1

answer
495

Views

Are parameters passed to subprocess safe in any way from code injection?

Are parameters passed to subprocess safe in any way from code injection? I am building a small python program to do some movie file tagging. For ease, I am passing the tag info to AtomicParsley (on Windows) using subprocess.call(). The tag information is an online source, retrieved automatically. If...
Sean K.
1

votes
1

answer
1.8k

Views

Get an error when building chrome, subprocess.call throws “No such file or directory”

Traceback (most recent call last): File "scripts/rule_bison.py", line 75, in return Code = subprocess.call([bisonExe, '-d', '-p', prefix, inputFile, '-o', outputCpp]) File "/usr/lib/python2.7/subprocess.py", line 493, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.7/subpro...
dreamevil
1

votes
2

answer
1.3k

Views

running TCL through python by subprocess, but not giving any output

I am trying to run my tcl script through python subprocess as follow: import subprocess >>> subprocess.Popen(["tclsh", "tcltest.tcl"]) >>> subprocess.Popen(["tclsh", "tcltest.tcl"], shell=True ) I don't know if it is working or not, since I don't see any anything from it! my tcl script also has some...
Sonic
1

votes
3

answer
1.7k

Views

how to send tab-key to python subprocess's stdin

Background: I have a Python subprocess that connects to a shell-like application, which uses the readline library to handle input, and that app has a TAB-complete routine for command input, just like bash. The child process is spawned, like so: def get_cli_subprocess_handle(): return subprocess.Po...
Trevor
1

votes
1

answer
3.1k

Views

subprocess.call vs os.system python

First time questioning here: I have a need to map a network drive in windows. The location is an internal sharepoint document library. In the cmd window: net use g: http://na.com/DMP/DMP/programming/ is successfull --> the command completed succeffuly os.system('"net use k: http://na.com/DMP/DMP/pr...
user2034000
1

votes
2

answer
582

Views

How to call a shell script from python in multiprocess?

I want to run a shell script behind, which does a specific job, simultaneously I will wait for the user's input to end the job. How can I achieve this? Here is my example code: from subprocess import call cmd = "internals/applog.sh " call([cmd]) raw_input("Press Y when you are done: ") The above cod...
Subho Halder
1

votes
1

answer
70

Views

How can I invoke a function from an imported module inside a class methode?

I am trying to make a small GUI program with tkinter. I need to use Python's subprocess.call() When I try to do so inside a class method I get following error: self.return_code = self.subprocess.call("echo Hello World", shell=True) AttributeError: 'App' object has no attribute 'subprocess' Here is...
Aashiq Hussain
1

votes
2

answer
2.3k

Views

Problems with subprocess, encoding and logging with sqlite

I have searched for quite a while for the answer to this question and I think a lot of it has to do with my unfamiliarity with how the subprocess module works. This is for a fuzzing program if anyone is interested. Also, I should mention that this is all being done in Linux (I think that is pertinen...
Daniel Kuntz
1

votes
1

answer
3.9k

Views

Subprocess.Popen: How to pass arguments without whitespace

Mighty people of Stackoverflow, I want to execute ./namecoind name_new d/ in a Python script with subprocess.popen where 'name' is a variable within the script. There are no spaces allowed between 'd/' and the variable. I tried this: p = subprocess.Popen(["./namecoind", "name_new", "d/", domainname...
Steffen
1

votes
1

answer
288

Views

Execute python command and shell command (using subprocess) sequentially

I am puzzled by the order of execution of python command and shell command (from subprocess). For example, I've got a simple code: import subprocess import shlex command="echo 'test'" arg=shlex.split(command) with open("out.txt", "w") as f: f.write("line1\n") subprocess.call(arg, stdout=f) f.write("...
dbrg77
1

votes
1

answer
2.5k

Views

how to give subprocess a password and get stdout at the same time

I'm trying to check for the existence of an executable on a remote machine, then run said executable. To do so I'm using subprocess to run ssh ls , and if that's successful, run ssh . ssh asks for a password, of course, and I'd like to provide that automatically. Also, I'd like to get the returnco...
Faentur
1

votes
1

answer
213

Views

Handling stdin and stdout

I'm trying to use subprocess to handle streams. I need to write data to the stream, and be able to read from it asynchronously (before the program dies, because mine's will take minutes to complete, however it products output). For the learn case, I've been using the timeout command from Windows 7:...
iTayb
1

votes
3

answer
508

Views

'cleartool find -print' inside Python3 'subprocess.check_output' returns empty string

I am trying to run the following command using Python subprocess /usr/atria/bin/cleartool find -follow -name '*.elf' -version "lbtype(CXC1111-111)" -print Code snippet: cmd = [clt, 'find', path, '-follow', '-name', '\"*.elf\"', '-version', lb, "-print"] try: output = subprocess.check_outpu...
Hemanth
1

votes
2

answer
1.1k

Views

Print multithread subprocess

Good day! I have a python script, it creates a file list and processes it in multiprocess.Pool.map and thread function. Thread function uses outside executable and calls it via subprocess.check_call. This outter executable prints some information to stdout. So I have problem with reading this outpu...
kvv
1

votes
3

answer
519

Views

logged subprocess.communicate()?

I have to call a script from Python and collect its output. So, p = subprocess.Popen ("script", shell = False, stdin = subprocess.PIPE, stdout = subprocess.PIPE) out_lines = p.communicate ("\n".join (in_lines)) [0] ... except I want to log every out_line as it comes in case, you know, the worst hap...
dan3
1

votes
2

answer
1.7k

Views

Extracting(not reading) a large gzip file with Python

I have a python script that is automating/coordinating the transfer and processing of several large gzip files. I need to be able to unzip them (like running gunzip file.log.gz in a shell), but don't need to (or want to) read them in - they will be passed to another command line tool that needs unzi...
user1514979
1

votes
3

answer
786

Views

Run python (unix) command with very low priority

I have a py script which reads data from db and loads into CSV file as below with open(filePath, 'a') as myfile: myfile.write(myline) Once the file is ready, my py script will initiate SQLLDR from subprocess.call(...) and loads all of them. I will have to do all of the above steps with very low pr...
Shashi
1

votes
1

answer
590

Views

gpg --passphrase-fd not working with python 3 subprocess

The following script encrypt_me.py (modified from another post) encrypts itself with gpg and prints out the ciphertext in armored form. However it only works on python2.7 but not python3? Do you have any idea what's wrong when it's running on python3? import subprocess import shlex import os import...
user1008204
1

votes
1

answer
2.9k

Views

Tkinter embed Graphical subprocess

I am trying to execute a compiled Pygame Graphical application from a Tkinter interface. However, I want the pygame interface to launch into a 800x600 Graphical frame. In the same root window below the 800x600 frame that is for the pygame application, I am looking for a way to embed either: a xterm...
AlexiK
1

votes
1

answer
1.2k

Views

p.stdout.read() doesn't work in my Python 3 codes

I try to create a sub-process using the subprocess module in MAC OS. Below is my code: import subprocess p = subprocess.Popen("app", stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) p.stdin.write(bytes("3\n", "ascii")) p.stdin.write(bytes("4\n", "ascii")) pr...
injoy
1

votes
1

answer
151

Views

How to make a big shell script in a single line shell script in json document?

I am working on Python along with bash shell script. I need to execute shell script from the Python script. I am successfully able to do that.. I need to have a shell script in a single line in a JSON String.. Below is an example which is working fine for a simple shell script which I have made it...
1

votes
1

answer
529

Views

Why does this python script only work from IDLE on Ubuntu 12.04?

Edit Written in C it works like a champ. I began noticing that the python would fail unpredictably. The bash solution worked too but I wanted to be able to easily check if it was running so I wrote the C version so I can see it when I do a ps -e. In an attempt to address this issue and the real prob...
JB0x2D1
1

votes
2

answer
410

Views

Using pipes with the python “subprocess” module

Let's say I want to call the program theprogram in a windows batch file. The code would look like this : exit | theprogram arg1 I've tested it and it works perfectly, many thanks ! Now, big change of strategy, I have to call theprogram inside a python script. For this I use the subprocess module. I...
Backslash36
1

votes
1

answer
1k

Views

Running a series commands non-synchronously from a .bat file

So here is my situation: I am calling a .bat file from a python script. I'm not sure if it's important, but I run the file with the python module subprocess. i.e. subprocess.call("dir/file.bat", shell=True) The .bat file creation is dependent on the user input during the python script execution, but...
Shakesbeery
1

votes
1

answer
157

Views

How to read output from subprocess without printing to terminal?

I've searched fairly thoroughly for an answer, but haven't found any solutions to this. I need to execute a child process only momentarily to print its version information. If run from the command line, it's simply .\bin\application.exe --version and version information is printed to the terminal....
swingsoneto
2

votes
1

answer
25

Views

run a subprocess in a python loop

I have for loop in python in each iteration of the loop I want to run a bash script and after its termination continue the loop and again run the bash script: for batch in something: proc = Popen(['./mybash.sh']) proc.wait() The mybash.sh script will compute something and display a value using echo....
pierre
1

votes
3

answer
1.8k

Views

why are '(single quote) or "(double quote) not allowed in subprocess.check_output() in python?

I am using subprocess.check_output() method to execute commands from within the python script. There are some commands that need "(double quotes) to be present in syntax. Here's one example: >drozer console connect -c "run app.package.info -a com.package.name" It throws error if we remove "(double q...
v1h5
1

votes
2

answer
304

Views

Why is Python Popen using a different executable

I have a program with two different versions on this computer. I can't get rid of the older one because I don't have root access, but I put the newer one first in 'bin' in my home directory (which is the first thing in my $PATH) I tried calling it with Python's Popen Popen(['clingo'...]...) and it...
dspyz
1

votes
2

answer
1.8k

Views

Wait for external program to finish writing to file

I have a Python script that calls an external program (sox to be precise). Now I have to do several things with sox, but always have to wait until one file is done writing so I can use it as an input file in my next command. subprocess.wait() doesn't work, because the execution of sox will be done,...
Sennster

View additional questions

Смотреть фильмы онлайн бабушка легкого поведения 2 фильм бесплатно