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


Groups > comp.lang.python > #36564

How to run multiline shell command within python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.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 <kliateni@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'subject:How': 0.09; 'python': 0.09; 'eof': 0.09; 'subject:command': 0.09; 'cc:addr:python-list': 0.10; 'sfxlen:2': 0.10; 'subject:python': 0.11; 'echo': 0.16; 'subject:run': 0.16; 'shell': 0.18; 'all,': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'lines': 0.28; 'run': 0.28; 'multiline': 0.29; 'code': 0.31; 'file': 0.32; 'to:addr:tutor': 0.33; 'received:74.125.82': 0.33; 'received:google.com': 0.34; 'skip:* 20': 0.35; 'received:192.168.0': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'received:74.125': 0.36; 'execute': 0.37; 'several': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'within': 0.64; 'making': 0.64; 'directly.': 0.78
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=i0bRUddHBBRgElUEaAeyP960bRjNJPA1KdtNHvdmITI=; b=ZC5hjJb7UIZAJzkFeVcvaCh+LGjkh5/kLf4kOm2EEhL03aloTsR9tgachKTLzy+nTu AqT2kFFyakD5qEX1PI5Y46l0ssMuqBlaVGVDH4UJB+UKGb3o8LbC/l9YjaQJezywN3ra O0YO9gSc5DkekqUffzQWuPBS4pkFlFV4X679FngKW3Rnc7gaywdcb2FC3cEE7/ZlEVwl aez7o947Zky2lnxyBILZhHEK6e83xN11sAp9H/0iym88sjos/y8OOzmjuSQAAp+GxlJr zRseUznRGz0Y5Ut/MFtNS4N2t/rh1LlwtoMFaVGqLrmp8Hf+xxrYebx0kMkgHYCYkoeu +mpA==
X-Received by 10.194.77.13 with SMTP id o13mr112442965wjw.58.1357797687464; Wed, 09 Jan 2013 22:01:27 -0800 (PST)
Date Thu, 10 Jan 2013 07:01:24 +0100
From Karim <kliateni@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version 1.0
To tutor@python.org
Subject How to run multiline shell command within python
References <b1c7ea47-47b4-4784-8037-e0856fdaa7cd@googlegroups.com>
In-Reply-To <b1c7ea47-47b4-4784-8037-e0856fdaa7cd@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.365.1357797689.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357797689 news.xs4all.nl 6922 [2001:888:2000:d::a6]:57710
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36564

Show key headers only | View raw



Hello all,

I want to run multiline shell command within python without using a 
command file but directly execute several lines of shell.
I already use *subprocess.checkoutput("csh -f my_file.csh".split())* but 
I want to know if it is posssible to avoid making file and execute
shell lines of code directly.

Example:

cat<<EOF > myfile
echo "foo"
echo "bar"
...
EOF

Regards

Karim

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


Thread

Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 15:52 -0800
  Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database John Gordon <gordon@panix.com> - 2013-01-10 00:08 +0000
    Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 16:19 -0800
      Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database Mitya Sirenef <msirenef@lightbird.net> - 2013-01-09 20:07 -0500
      Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database MRAB <python@mrabarnett.plus.com> - 2013-01-10 01:11 +0000
        Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 18:20 -0800
          Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database Mitya Sirenef <msirenef@lightbird.net> - 2013-01-09 21:56 -0500
        Re: Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database andydtaylor@gmail.com - 2013-01-09 18:20 -0800
  How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 07:01 +0100
  Re: [Tutor] How to run multiline shell command within python Hugo Arts <hugo.yoshi@gmail.com> - 2013-01-10 09:31 +0100
  Re: [Tutor] How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 15:25 +0100
  Re: [Tutor] How to run multiline shell command within python Matty Sarro <msarro@gmail.com> - 2013-01-10 10:21 -0500
  Re: [Tutor] How to run multiline shell command within python Karim <kliateni@gmail.com> - 2013-01-10 20:07 +0100

csiph-web