Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'string.': 0.05; 'sys': 0.07; 'subject:help': 0.08; 'subject:script': 0.09; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'macs': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'thu,': 0.19; 'code,': 0.22; 'import': 0.22; 'print': 0.22; '(a)': 0.24; 'looks': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'code': 0.31; 'crash': 0.31; 'selection': 0.32; 'run': 0.32; 'guess': 0.33; 'actual': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'everyone.': 0.36; 'doing': 0.36; 'wrong': 0.37; 'starting': 0.37; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'hope': 0.61; 'simple': 0.61; "you're": 0.61; 'back': 0.62; 'decided': 0.64; 'subject:Need': 0.64; 'here': 0.66; 'home': 0.69; 'jul': 0.74; '11:44': 0.84; 're-type': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=gHuBPX9dMxEghG8s/dM127mjCFM10OfG5/Ah91bqoCs=; b=WczlfEjlL7T4QkPfkn9W6reK2Syq7ne2s10bNkB4DH+iWRc8zLGvG1AEq7nohiBvr1 Ang8EYpaBmtxg5P3myfF4VIa+j5JaQspbnk9taiqd/ZcFtooRJwlX+CQgD2QXrpuMEFG RCZQhxau/Ba8NYqhtStXDIO4hkRcCM7SL02sz6OD22EP9es4hoRQVBtzVoiE97KCSyOq X2iPiIqFvWaQPpMTRAjKeaVcFpR+xnENqv0KJwUMZedgu5uFqrAKa1Ot2RIatsveYBy7 0HvKxK4CVNDuTW8St3ShCdEiU2lCBzjxOdX7Ed+vyw2r7YosV8ixcM1yxzW5bVN6Jljz SkGA== MIME-Version: 1.0 X-Received: by 10.58.249.236 with SMTP id yx12mr3150580vec.25.1374112244794; Wed, 17 Jul 2013 18:50:44 -0700 (PDT) In-Reply-To: References: Date: Thu, 18 Jul 2013 11:50:44 +1000 Subject: Re: Need help with network script From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374112253 news.xs4all.nl 15891 [2001:888:2000:d::a6]:39192 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50816 On Thu, Jul 18, 2013 at 11:44 AM, wrote: > Hi everyone. I am starting to learn python and I decided to start with wh= at I though was a simple script but I guess now. All I want to do is return= what current network location I am using on my mac. Every time I run it, i= t gives me back a 0. I don't know what I am doing wrong so here is my code.= I really hope some one can help me. This script is unique to MACS btw. > > import sys > import subprocess > > loc =3D "scselect" > srn =3D "scselect SRN" > home =3D "scselect HOME" > > a =3D subprocess.call(loc, shell=3DTrue, stdout=3Dsubprocess.PIPE) > b =3D subprocess.call(srn, shell=3DTrue, stdout=3Dsubprocess.PIPE) > c =3D subprocess.call(home, shell=3DTrue, stdout=3Dsubprocess.PIPE) > > print "\n##### NETWORK SELECTION #####" > print "\nYour current location is set to \n%s" (a) Your last line here looks wrong. Is this really the code you're using? This code will crash with a TypeError, because you're trying to call a string. Copy and paste your actual code, don't re-type it :) ChrisA