Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

problem with subprocess

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


gabrielmonnerat at gmail

Jul 10, 2009, 9:36 AM

Post #1 of 3 (547 views)
Permalink
problem with subprocess

Hi all,

I need start a openoffice in Xvfb, but when I call with the DISPLAY
occurs this error:

[root [at] localhos oood]# Xvfb :99 -screen 0 1024x768x24 &

In [9]: subprocess.call('/opt/ooo-dev3/program/soffice.bin')
Out[9]: 0

In [10]: subprocess.call('DISPLAY=:99 /opt/ooo-dev3/program/soffice.bin')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)

/home/gabriel/<ipython console> in <module>()

/usr/lib/python2.6/subprocess.pyc in call(*popenargs, **kwargs)
442 retcode = call(["ls", "-l"])
443 """
--> 444 return Popen(*popenargs, **kwargs).wait()
445
446

/usr/lib/python2.6/subprocess.pyc in __init__(self, args, bufsize,
executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd,
env, universal_newlines, startupinfo, creationflags)
593 p2cread, p2cwrite,
594 c2pread, c2pwrite,
--> 595 errread, errwrite)
596
597 # On Windows, you cannot just redirect one or two
handles: You


/usr/lib/python2.6/subprocess.pyc in _execute_child(self, args,
executable, preexec_fn, close_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite,
errread, errwrite)
1104 os.waitpid(self.pid, 0)
1105 child_exception = pickle.loads(data)
-> 1106 raise child_exception
1107
1108

OSError: [Errno 2] No such file or directory

I am using subprocess because I need store the pid. Any suggestions?

thanks in advance,

Gabriel M. Monnerat

--
http://mail.python.org/mailman/listinfo/python-list


gabrielmonnerat at gmail

Jul 10, 2009, 9:48 AM

Post #2 of 3 (519 views)
Permalink
Re: problem with subprocess [In reply to]

gabrielmonnerat wrote:
> Hi all,
>
> I need start a openoffice in Xvfb, but when I call with the DISPLAY
> occurs this error:
>
> [root [at] localhos oood]# Xvfb :99 -screen 0 1024x768x24 &
>
> In [9]: subprocess.call('/opt/ooo-dev3/program/soffice.bin')
> Out[9]: 0
>
> In [10]: subprocess.call('DISPLAY=:99 /opt/ooo-dev3/program/soffice.bin')
> ---------------------------------------------------------------------------
>
> OSError Traceback (most recent call
> last)
>
> /home/gabriel/<ipython console> in <module>()
>
> /usr/lib/python2.6/subprocess.pyc in call(*popenargs, **kwargs)
> 442 retcode = call(["ls", "-l"])
> 443 """
> --> 444 return Popen(*popenargs, **kwargs).wait()
> 445
> 446
>
> /usr/lib/python2.6/subprocess.pyc in __init__(self, args, bufsize,
> executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd,
> env, universal_newlines, startupinfo, creationflags)
> 593 p2cread, p2cwrite,
> 594 c2pread, c2pwrite,
> --> 595 errread, errwrite)
> 596
> 597 # On Windows, you cannot just redirect one or two
> handles: You
>
>
> /usr/lib/python2.6/subprocess.pyc in _execute_child(self, args,
> executable, preexec_fn, close_fds, cwd, env, universal_newlines,
> startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread,
> c2pwrite, errread, errwrite)
> 1104 os.waitpid(self.pid, 0)
> 1105 child_exception = pickle.loads(data)
> -> 1106 raise child_exception
> 1107
> 1108
>
> OSError: [Errno 2] No such file or directory
>
> I am using subprocess because I need store the pid. Any suggestions?
Sorry, I was forgot the parameter shell=True.
i.e
In [20]: subprocess.call('DISPLAY=:99
/opt/ooo-dev3/program/soffice.bin',shell=True)

lack of attention mine
>
> thanks in advance,
>
> Gabriel M. Monnerat
>
>
Gabriel M. Monnerat
--
http://mail.python.org/mailman/listinfo/python-list


lists at cheimes

Jul 10, 2009, 10:21 AM

Post #3 of 3 (526 views)
Permalink
Re: problem with subprocess [In reply to]

gabrielmonnerat wrote:
>> I am using subprocess because I need store the pid. Any suggestions?
> Sorry, I was forgot the parameter shell=True.
> i.e
> In [20]: subprocess.call('DISPLAY=:99
> /opt/ooo-dev3/program/soffice.bin',shell=True)

You should avoid using the shell=True parameter. It may result in
security issues and it consumes more resources. Try this:

env = os.environ.copy()
env["DISPLAY"] = ":99"
subprocess.call(['opt/ooo-dev3/program/soffice.bin', env=env)

Christian

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.