Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43701

Re: Calling python script in dos and passing arguments

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'string': 0.09; 'escape': 0.09; 'python:': 0.09; 'subject:script': 0.09; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'backslash': 0.16; 'escapes': 0.16; 'misfeature': 0.16; 'values:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'library': 0.18; 'trying': 0.19; 'pfxlen:0': 0.19; 'input': 0.22; 'import': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; 'pass': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'character': 0.29; "doesn't": 0.30; 'dos': 0.30; 'expansion': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'another': 0.32; 'open': 0.33; 'url:python': 0.33; '(e.g.': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:s 60': 0.36; 'done': 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:library': 0.38; 'that,': 0.38; 'does': 0.39; 'called': 0.40; 'how': 0.40; 'to:addr:gmail.com': 0.65; 'due': 0.66; 'invalid': 0.68; 'default': 0.69; 'therefore': 0.72; 'sender:addr:chris': 0.84; 'shell,': 0.91; 'yourself,': 0.95; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=WyTMoUxpgG5VbA+faEi0gTcFsebnr9jXlbeVXVjWoFs=; b=aBOLRjsRJ9m/iD8EG9EnoNphjxXpaOGfv4397mcvFJ35OVHhwAe+vlPbmdwjVXAYvI I6r1aeVVGeIdvvuYKNrT0nWNtvzHgbP43Ge0SuluxENKgxiOYfm0L/V9BKsDhDNKV5Ai x8JsMd57gD15EmBAfDQ/ldiD+Fsq+TvARjXb4=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=WyTMoUxpgG5VbA+faEi0gTcFsebnr9jXlbeVXVjWoFs=; b=VxDGJruTBDz/xosYP5/pWs1jn3r4EqUkitkVPHRo30U+7L28Hb/YV7kHOSt3wFXWLi Otej6dyQQfRfSQVR6ATQPyZlYTc7tarcDvrXZ6CWrpKuKVdLhXdCDemWTBG8xqbotaRW 2DtflJV8r+COyoY3aCUw+oaw4aTluYKHosT+SHmodYJyKe3LlDGClYclgNNuyFAcQWa5 Do6/4Cs9Ya9ZIBQ0tx0hE7ODXreMX7o5UO2Ep9xCLgTGZCoGcn9AI0kSZYtjnfVeFvao UivqyAKUvq8cAIjgpP1RyTZ3Zjs7S/Im4ZSN4UIMnBIGZmJNM9l7kHX7BJXy90w4YQDp YPIA==
MIME-Version 1.0
X-Received by 10.50.53.176 with SMTP id c16mr2197819igp.36.1366139409838; Tue, 16 Apr 2013 12:10:09 -0700 (PDT)
Sender chris@rebertia.com
In-Reply-To <88b87ac0-1fce-4383-9841-d99a49f50556@googlegroups.com>
References <88b87ac0-1fce-4383-9841-d99a49f50556@googlegroups.com>
Date Tue, 16 Apr 2013 12:10:09 -0700
X-Google-Sender-Auth u3olGQS_L6n-K87q-K0TvnAegzk
Subject Re: Calling python script in dos and passing arguments
From Chris Rebert <clp2@rebertia.com>
To PEnergy <prquinn@gmail.com>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQmt0zRoBo0ZPoQYoVtLL5ZGAg35UOV/N2z33kIe+o/LyzQ2Ka8+zEVku6eYuTrH0nHjCbjl
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.688.1366139419.3114.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366139419 news.xs4all.nl 2568 [2001:888:2000:d::a6]:44824
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43701

Show key headers only | View raw


On Tue, Apr 16, 2013 at 7:14 AM, PEnergy <prquinn@gmail.com> wrote:
> Greetings,
>
> I am trying to write a python script that, when called from the DOS prompt, will call another python script and pass it input variables.  My current code will open the other python script but doesn't seem to pass it any values:
>
> import os,sys,subprocess
> subprocess.Popen(['python.exe','C:\NDEX\GRE2\uip\uip_20.py','t3c*'])
>
> Am I missing something or is this type of call not possible through DOS?

1. Backslash is an escape character in Python strings (e.g. "\n" =
newline). You should therefore double-up on your backslashes. (Your
exact string just so happens to work due to a misfeature regarding how
invalid backslash escapes are handled.)
2. Glob/wildcard ("*") expansion is done by the shell, but
subprocess.Popen does not use the shell by default (for good reason!).
Use the `glob` library to do the expansion yourself, in Python:
http://docs.python.org/2/library/glob.html

Cheers,
Chris

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Calling python script in dos and passing arguments PEnergy <prquinn@gmail.com> - 2013-04-16 07:14 -0700
  Re: Calling python script in dos and passing arguments Chris Rebert <clp2@rebertia.com> - 2013-04-16 12:10 -0700
    Re: Calling python script in dos and passing arguments Alister <alister.ware@ntlworld.com> - 2013-04-16 19:19 +0000
    Re: Calling python script in dos and passing arguments Tim Roberts <timr@probo.com> - 2013-04-16 22:32 -0700
  Re: Calling python script in dos and passing arguments Michael Torrie <torriem@gmail.com> - 2013-04-16 13:25 -0600

csiph-web