Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86004
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| 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; 'example:': 0.03; 'argument': 0.05; 'output': 0.05; 'debug': 0.07; 'debugging': 0.07; 'removes': 0.07; 'brad': 0.09; 'line:': 0.09; 'output,': 0.09; 'skip:> 40': 0.09; 'subject:command': 0.09; 'python': 0.11; '%r"': 0.16; '>the': 0.16; 'compute': 0.16; 'did,': 0.16; 'fine.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'list"': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'outputs': 0.16; 'reproduce': 0.16; 'robust.': 0.16; 'simpson': 0.16; 'skip:> 20': 0.16; 'subject:fails': 0.16; 'supplied': 0.16; 'accordingly.': 0.16; 'files.': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'user.': 0.19; 'command': 0.22; 'input': 0.22; 'separate': 0.22; 'shell': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'stick': 0.24; 'cheers,': 0.24; 'question': 0.24; 'script': 0.25; 'first,': 0.26; 'purposes': 0.26; 'skip:" 40': 0.26; 'post': 0.26; 'code:': 0.26; 'header:In- Reply-To:1': 0.27; 'code': 0.31; "skip:' 10": 0.31; 'bunch': 0.31; 'file': 0.32; 'run': 0.32; 'something': 0.35; 'one,': 0.35; 'but': 0.35; 'skip:> 10': 0.36; 'skip:s 60': 0.36; 'surely': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'error.': 0.37; 'example,': 0.37; 'two': 0.37; 'list': 0.37; 'to:addr :python-list': 0.38; 'files': 0.38; 'skip:- 10': 0.38; 'quote': 0.39; 'to:addr:python.org': 0.39; 'remove': 0.60; 'skip:u 10': 0.60; 'commands': 0.60; 'skip:z 20': 0.60; 'first': 0.61; 'content-disposition:inline': 0.62; 'kind': 0.63; 'more': 0.64; 'hand': 0.80; 'clearly.': 0.84; 'optin': 0.84; 'received:192.168.15': 0.84; 'skip:g 100': 0.84; 'write:': 0.91; 'obtained': 0.96 |
| Date | Sat, 21 Feb 2015 12:11:57 +1100 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | python-list@python.org |
| Subject | Re: subprocess command fails |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Disposition | inline |
| Content-Transfer-Encoding | quoted-printable |
| In-Reply-To | <c03d11a3-33d3-4b8c-a966-34181e1b5bfd@googlegroups.com> |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| References | <c03d11a3-33d3-4b8c-a966-34181e1b5bfd@googlegroups.com> |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18940.1424481128.18130.python-list@python.org> (permalink) |
| Lines | 98 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424481128 news.xs4all.nl 2943 [2001:888:2000:d::a6]:58086 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:86004 |
Show key headers only | View raw
On 20Feb2015 15:30, Brad s <bcddd214@gmail.com> wrote:
>I am trying to execute a subprocess, something done in my script a couple of times. But on the last one, it outputs an error I cannot find the solution to. The exact same command using the same files produced at the command line works just fine.
>
Hi Brad,
I have reordered your post in my quote for readability. It is best to ask your
question and give some background first, then list offending output with a
description of good output, then the code.
You write:
>The first command works on the command line:
>
>dnssec-signzone -e20180330000000 -p -t -g -k Ktest123.com.ksk.key -o test123.com test123.com.external Ktest123.com.zsk.key
>Verifying the zone using the following algorithms: RSASHA256.
>Zone fully signed:
>Algorithm: RSASHA256: KSKs: 1 active, 0 stand-by, 0 revoked
> ZSKs: 1 active, 0 stand-by, 0 revoked
>test123.com.external.signed
>Signatures generated: 9
>Signatures retained: 0
>Signatures dropped: 0
>Signatures successfully verified: 0
>Signatures unsuccessfully verified: 0
>Signing time in seconds: 0.010
>Signatures per second: 875.401
>Runtime in seconds: 0.013
Which is excellent.
Then you supply your code:
>sfmove = subprocess.call(['dnssec-signzone','-e',strftime('%Y%m%d%H', gmtime())+'0000','-p','-t','-g','-k',zcombined+'.ksk.key','-o',dname,dname+'.external',zcombined+'.zsk.key'])
I would start by pointing out that this is not identical to your shell command
line. FOr example, your shell command line supplied the -e optin as
"-e20180330000000", but your python code generates two strings: "-e",
"20180330000000".
It may not matter, but it is not identically worded and some commands are picky
about this kind of thing.
For debugging purposes I would do two things:
- compute the python command argument list as a separate list and print it out, example:
cmdargv = [ 'dnssec-signzone',
'-e', strftime('%Y%m%d%H', gmtime())+'0000',
'-p',
'-t',
'-g',
'-k', zcombined+'.ksk.key',
'-o', dname,
dname+'.external',
zcombined+'.zsk.key'
]
print("command = %r" % (cmdargv,))
sfmove = subprocess.call(cmdargv)
Note the use of %r to print the contents of the command clearly.
(BTW, "sfmove"? Surely "sign" or something.)
- hand run _exactly_ the command printed out by the print call above
If you run _exactly_ what your python comman did, you should be able to
reproduce the error. Then debug on the command line. Then fix the python code
accordingly.
>#cmd = "dnssec-signzone','-e',strftime('%Y%m%d%H', gmtime())+'0000','-p','-t','-g','-k','K'+dname+'.ksk.key','-o',dname,dname+'.external','K"+dname+'.zsk.key'
>#subprocess.check_call(shlex.split(cmd))
Remark: shlex.split is not a good way to make a command line unless it comand
from some input line obtained from a user. Stick with your current "construct a
list" approach: more robust.
I notice your code removes a bunch of files. Might it remove a necessary file
for the command?
Cheers,
Cameron Simpson <cs@zip.com.au>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 15:30 -0800
Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 12:11 +1100
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 20:47 -0800
Re: subprocess command fails Larry Hudson <orgnut@yahoo.com> - 2015-02-21 12:33 -0800
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 21:14 -0800
Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 17:47 +1100
Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 22:41 -0800
csiph-web