[Python] Esecuzione dnscmd con python3

Marco Passanisi mpxnet a gmail.com
Lun 21 Ott 2013 15:25:29 CEST


si mi da sempre errore.


2013/10/21 Raffaele Salmaso <raffaele a salmaso.org>

> 2013/10/21 Marco Passanisi <mpxnet a gmail.com>:
> > import subprocess
> >
> > output = subprocess.Popen('"c:\Windows\system32\dnscmd.exe" ns-01
> > /enumzones', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> > out, err = output.communicate()
> http://docs.python.org/3.3/library/subprocess.html
>
> """
> args should be a sequence of program arguments or else a single
> string. By default, the program to execute is the first item in args
> if args is a sequence. If args is a string, the interpretation is
> platform-dependent and described below. See the shell and executable
> arguments for additional differences from the default behavior. Unless
> otherwise stated, it is recommended to pass args as a sequence.
> ...
> On Windows, if args is a sequence, it will be converted to a string in
> a manner described in Converting an argument sequence to a string on
> Windows. This is because the underlying CreateProcess() operates on
> strings.
> ...
> On Windows with shell=True, the COMSPEC environment variable specifies
> the default shell. The only time you need to specify shell=True on
> Windows is when the command you wish to execute is built into the
> shell (e.g. dir or copy). You do not need shell=True to run a batch
> file or console-based executable.
> """
> hai provato a passare i comandi come una lista di argomenti?
> output = subprocess.Popen([ "c:\Windows\system32\dnscmd.exe", "ns-01",
> "/enumzones" ], shell=True, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
>
> > print(err)
> > b'""c:\\Windows\\system32\\dnscmd.exe"" non \x8a riconosciuto come
> comando
> > interno o esterno,\r\n un programma eseguibile o un file batch.\r\n'
> ed infatti cerca di eseguire "c:\\Windows\\system32\\dnscmd.exe" che è
> diverso da c:\\Windows\\system32\\dnscmd.exe
>
> --
> | Raffaele Salmaso
> | http://salmaso.org
> | https://bitbucket.org/rsalmaso
> | http://gnammo.com
> _______________________________________________
> Python mailing list
> Python a lists.python.it
> http://lists.python.it/mailman/listinfo/python
>
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20131021/5431a395/attachment-0001.html>


Maggiori informazioni sulla lista Python