Questions tagged [os.execl]
33 questions
81
votes
7 answers
Launch a shell command with in a python script, wait for the termination and return to the script
I have a python script that has to launch a shell command for every file in a dir:
import os
files = os.listdir(".")
for f in files:
os.execlp("myscript", "myscript", f)
This works fine for the first file, but after the "myscript" command has…

Davide Gualano
- 12,813
- 9
- 44
- 65
9
votes
3 answers
What does os.execl do exactly? Why am I getting this error?
I'm running into some trouble with deploying Django on the passenger_wsgi module with virtualenv. The Python code in the passenger_wsgi.py file, which should fix my problem is:
import os, sys
INTERP =…

Monika Sulik
- 16,498
- 15
- 50
- 52
8
votes
2 answers
Difference between os.execl() and os.execv() in python
Is there a difference between os.execl() and os.execv() in python? I was using
os.execl(python, python, *sys.argv)
to restart my script (from here). But it seems to start from where the previous script left.
I want the script to start from the…

Rohin Kumar
- 730
- 2
- 10
- 24
5
votes
1 answer
Replace a running python script with os.execl
I may not be looking hard enough but I am trying to replace a running python script with another python script. Based on the research that I have done, using the os.execl function may be what I am looking for. I am a little bit confused about the…

user3286192
- 95
- 1
- 7
3
votes
2 answers
open() fails at first attempt
open() fails with ENOENT (no such file or directory) on first attempt but works fine in subsequent attempts.
My program forks a child process and and waits for the child to finish using waitpid(). The child process creates a copy of a file path…

Mithun Ganatra
- 453
- 4
- 21
3
votes
2 answers
How to redirect stdin/stdout/stderr when replacing process using os.execl
Consider the following sample script:
import os
import sys
print(1)
os.execl(sys.executable, sys.executable, '-c', 'print(2)')
print(3)
The result is
1
I was expecting
1
2
I think it is because the replacing process is not using the same…

AXO
- 8,198
- 6
- 62
- 63
3
votes
1 answer
Why shows --"cannot pass objects of non-trivially-copyable type"?
You don't have to go through the complete code from the beginning. The problem is in the execl(..) statement inside main. Code is --
#include
#include
#include
#include
#include
#include…

Pavel
- 138
- 2
- 4
- 16
2
votes
1 answer
execlp multiple "programs"
I want to run something like
cat file.tar | base64 | myprogram -c "| base64 -d | tar -zvt "
I use execlp to run the process.
When i try to run something like cat it works, but if i try to run base64 -d | tar -zvt it doesn't work.
I looked at the…

Lefsler
- 1,738
- 6
- 26
- 46
2
votes
2 answers
OSError : [Errno 12] Not enough Space on os.execl call
So I was messing around with a script that is supposed to restart itself using os.execl.
It is working a few times but after ~ 30 or 40 calls it crashes;
Traceback (most recent call last):
File…

Core taxxe
- 299
- 2
- 12
2
votes
0 answers
Can't restart Python script os.exec*()
I basically want to restart the current script I'm running. So to do that I need to use some of the os.exec*() functions. But I don't want to pass in any parameters, I'm not sure how to actually start the…

HelloThereToad
- 249
- 1
- 3
- 14
2
votes
3 answers
execl doesn't work in a while(1) loop, server side; C script
I have a problem with a little C script which should run as a server and launch a popup for every message arriving.
The execl syntax is correct because if I try a little script with
main() { execl(...); }
it works.
When I put it in a while(1) loop…

Possa
- 2,067
- 7
- 20
- 22
2
votes
1 answer
Passing argument with *list doesn't work with execl
I have a python script which acts as launcher for other scripts. The script launches scripts from input arguments, following is some relevant code:
try:
if verbose:
print("Calling script ", args.script, " with arguments",…

Zagorax
- 11,440
- 8
- 44
- 56
1
vote
2 answers
telling when an execl() process exits
I've got a c++ application with certain items in a queue, those items then are going to be processed by a python script. I want it so that at maximum 10 instances of the python script are running. I plan on using execl() to launch the python…

whatWhat
- 3,987
- 7
- 37
- 44
1
vote
0 answers
How can python access the process name that is passed to execl as the second argument
Consider the following script saved as test.py:
from sys import argv, executable
from os import execl
print(argv)
if argv[1] == 'a':
argv[1] = 'b'
print('execl')
execl(executable, 'process_name', *argv)
print('the interpreter will…

AXO
- 8,198
- 6
- 62
- 63
1
vote
1 answer
Why am I getting an "execv(file, args)" error when using execl()?
I am trying to use execl() to execute a new program but it keeps returning an execv() error saying that arg2 must not be empty.
if pid == 0:
print("This is a child process")
print("Using exec to another program")
…

Andy
- 7
- 7