Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'ok.': 0.04; '>>>>': 0.09; 'args,': 0.09; 'interpreting': 0.09; 'skip:o 50': 0.09; 'unix,': 0.09; 'pm,': 0.11; 'linux': 0.11; 'received:74.125.82.44': 0.14; 'received:mail-ww0-f44.google.com': 0.14; 'wrote:': 0.14; '"on': 0.16; '[errno': 0.16; '__init__': 0.16; 'oserror:': 0.16; 'stderr.': 0.16; 'stdout': 0.16; 'subject:file': 0.16; 'traceback': 0.16; '(most': 0.16; 'thanks,': 0.17; 'url:blog': 0.18; 'fine': 0.18; 'command': 0.19; 'obviously': 0.20; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'header :In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'mon,': 0.22; 'specified': 0.22; 'trying': 0.23; 'last):': 0.23; "i'm": 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'string': 0.29; 'hi,': 0.29; 'skip:" 30': 0.29; "skip:' 30": 0.29; 'named': 0.30; 'cc:addr:python.org': 0.31; 'url:library': 0.31; 'url:docs': 0.33; 'file': 0.35; 'finding': 0.35; '"",': 0.35; 'subject: ?': 0.35; 'appreciated.': 0.36; 'error.': 0.36; 'url:python': 0.37; 'run': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'url:org': 0.38; 'used': 0.38; 'help': 0.39; 'how': 0.39; 'works': 0.40; 'header:Received:5': 0.40; 'learn': 0.60; 'exact': 0.60; '2011': 0.62; 'subject:such': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ycgAJKbsU70jvUFScE2ymUojEHia4bNfmdV2B5QRtqc=; b=I566iB61NpCIXghms6/j2WQ866tQEawBvZ4Il+Ggo53dQx1H0pxac8rt6ZqCLARUic Er4bLBZXrE4PM9kb+zLS8i5uWJlwwSm/lSvnGVroi8o68fg2OaK9GUYcVy58zfX+p1tc 7DCLMWeSsnsdbbFxCm3xv2K2Jl4YHUtenyb9o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ELJNG36M/rh7fNGdwUyVMtCuTx56nDJRQcNcKTc5MtSJq0oorpKxJOepZGtXA+A22q sP4UGa7vgRfslUuSzVbMO9TWPqkF2/+2Fd3gz4Atvrv8kapBPV2LsTTzDyImF63ygkIn OKbIGCBMLu/kvkJmb+RJkiyF4S7uh/V434GKA= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <8bb1fd96-91bf-42f6-a7ea-ab060cd22f66@a19g2000prj.googlegroups.com> References: <8bb1fd96-91bf-42f6-a7ea-ab060cd22f66@a19g2000prj.googlegroups.com> Date: Mon, 18 Apr 2011 16:36:06 -0700 X-Google-Sender-Auth: lFRFzvna6sau0ok_RQOvLxI6s0k Subject: Re: Popen to get stdout and stderr for ffmpeg - No such file or directory ? From: Chris Rebert To: goldtech Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303169769 news.xs4all.nl 81483 [::ffff:82.94.164.166]:52717 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3510 On Mon, Apr 18, 2011 at 4:07 PM, goldtech wrote: > Hi, > > Trying to learn how to run a linux command and get the stdout and > stderr. I'm trying the following: > >>>> cmd3 =3D r'ffmpeg -i /home/giga/Desktop/Guitar1.flv' >>>> p =3D Popen(cmd3, stdout=3DPIPE, stderr=3DPIPE) > > Traceback (most recent call last): > =C2=A0File "", line 1, in > =C2=A0 =C2=A0p =3D Popen(cmd3, stdout=3DPIPE, stderr=3DPIPE) > =C2=A0File "/usr/lib/python2.6/subprocess.py", line 623, in __init__ > =C2=A0 =C2=A0errread, errwrite) > =C2=A0File "/usr/lib/python2.6/subprocess.py", line 1141, in > _execute_child > =C2=A0 =C2=A0raise child_exception > OSError: [Errno 2] No such file or directory > > But: > >>>> if os.path.exists(r'/home/giga/Desktop/Guitar1.flv'): > =C2=A0 =C2=A0 =C2=A0 =C2=A0print "exist" > Also if I run the exact command (cmd3) in the terminal it works OK. > Why is it not finding the file? Thanks, help appreciated. Read The Fine Manual: http://docs.python.org/library/subprocess.html#subprocess.Popen : "On Unix, with shell=3DFalse (default): [...] If a string is specified for args, it will be used as the name or path of the program to execute; ***this will only work if the program is being given no arguments.***" (emphasis added) The system is interpreting the entire command string as the path to an executable; obviously there's no directory named "ffmpeg -i ", so the path is invalid, hence the error. Try instead: cmd3 =3D ['ffmpeg', '-i', '/home/giga/Desktop/Guitar1.flv'] Cheers, Chris -- http://blog.rebertia.com