Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing && in subprocess.Popen for command chaining?
    primarykey
    data
    text
    <p>I'm using <code>subprocess.Popen</code> with <code>Python</code>, and I haven't come across an elegant solution for joining commands (i.e. foobar<code>&amp;&amp;</code> bizbang) via <code>Popen</code>.</p> <p>I could do this:</p> <pre><code>p1 = subprocess.Popen(["mmls", "WinXP.E01"], stdout=subprocess.PIPE) result = p1.communicate()[0].split("\n") for line in result: script_log.write(line) script_log.write("\n") p1 = subprocess.Popen(["stat", "WinXP.E01"], stdout=subprocess.PIPE) result = p1.communicate()[0].split("\n") for line in result: script_log.write(line) </code></pre> <hr> <p>But that really isn't very aesthetically pleasing (especially if I'm daisy-chaining multiple commands via <code>Popen</code>.</p> <hr> <p><strong>I'd like to replicate this output in as few command blocks as possible.</strong></p> <pre><code>not@work ~/ESI/lab3/images $ mmls WinXP.E01 &amp;&amp; echo -e "\n" &amp;&amp; stat WinXP.E01 DOS Partition Table Offset Sector: 0 Units are in 512-byte sectors Slot Start End Length Description 00: Meta 0000000000 0000000000 0000000001 Primary Table (#0) 01: ----- 0000000000 0000000062 0000000063 Unallocated 02: 00:00 0000000063 0020948759 0020948697 NTFS (0x07) 03: ----- 0020948760 0020971519 0000022760 Unallocated File: `WinXP.E01' Size: 4665518381 Blocks: 9112368 IO Block: 4096 regular file Device: 14h/20d Inode: 4195953 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ nott) Gid: ( 1000/ nott) Access: 2013-03-16 23:20:41.901326579 -0400 Modify: 2013-03-04 10:05:50.000000000 -0500 Change: 2013-03-13 00:25:33.254684050 -0400 Birth: - </code></pre> <hr> <h2>Any suggestions?</h2> <p>Note: I'd like to avoid typing this into <code>subprocess.Popen</code></p> <pre><code>p1 = subprocess.Popen(["mmls WinXP.E01 &amp;&amp; echo -e '\n' &amp;&amp; stat WinXP.E01"], stdout=subprocess.PIPE) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload