Subprocess quote problem

Adriano Monteiro py.adriano at gmail.com
Fri Aug 18 06:54:26 EDT 2006


Hi Folks,

I'm working on a script that executes a command with arbitrary
options. Most of its options works fine with subprocess, but at least
one (as far as I know) is giving me a headache. The program that I'm
trying to execute is Nmap, and the problematic option is the -iL, that
is used to indicate a file with the targets that nmap should scan.

If I open my terminal, and write: nmap -iL "/tmp/target_list" , nmap
picks the file, read it and scan every target written inside it.

But, if I try to use the same scan on my command execution script, it
makes nmap raise a strange error:

"Failed to open input file "/home/adriano/umit/test/targets" for reading
QUITTING!"


This is not a permission issue. I put this target_file file on /tmp
and set chmod 777 on it.


The script:

<code>
_stdout_handler = open(self.stdout_output, "w+")
_stderr_handler = open(self.stderr_output, "w+")
command = ['nmap', '-T', 'Aggressive', '-n', '-F', '-iL',
'"/home/adriano/umit/test/targets"']

command_process = Popen(command, bufsize=1,
                                              stdin=PIPE,
                                              stdout=_stdout_handler.fileno(),
                                              stderr=_stderr_handler.fileno(),
                                              shell=False)
</code>

The problem seens to be the double quoted path. But it doesn't make
any sense for me, as any other command that I put there works fine.

Any clue?


Cheeers!

-- 
Adriano Monteiro Marques
http://umit.sourceforge.net
py.adriano at gmail.com

"Don't stay in bed, unless you can make money in bed." - George Burns



More information about the Python-list mailing list