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


Groups > comp.lang.python > #43703

Re: Calling python script in dos and passing arguments

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem@gmail.com>
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; 'args': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'arguments': 0.09; 'attributes': 0.09; 'imported': 0.09; 'subject:script': 0.09; 'variables.': 0.09; 'python': 0.11; 'def': 0.12; 'command-line': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'scripts.': 0.16; 'values:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'input': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'form:': 0.24; 'parse': 0.24; 'script': 0.25; 'pass': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'dos': 0.30; 'code': 0.31; 'easier': 0.31; 'usually': 0.31; 'run': 0.32; 'another': 0.32; 'open': 0.33; 'but': 0.35; 'skip:s 60': 0.36; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'such': 0.63; 'approach.': 0.91
X-Virus-Scanned amavisd-new at torriefamily.org
Date Tue, 16 Apr 2013 13:25:22 -0600
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: Calling python script in dos and passing arguments
References <88b87ac0-1fce-4383-9841-d99a49f50556@googlegroups.com>
In-Reply-To <88b87ac0-1fce-4383-9841-d99a49f50556@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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.689.1366140333.3114.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366140333 news.xs4all.nl 2617 [2001:888:2000:d::a6]:52235
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43703

Show key headers only | View raw


On 04/16/2013 08:14 AM, PEnergy 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*'])

I find it easier just to write my python programs such that they can be
imported into other python scripts.  Usually I use this form:

def func(*whatever):
    pass

if __name__ == "__main__":
  # parse command-line arguments
  # call functions in this module with those args
  func(1,2,3,etc)

This way a script can be run standalone, or I can import it and access
its attributes direction.  I recommend you consider this approach.

Back to comp.lang.python | Previous | NextPrevious 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