Subprocess quote problem



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@xxxxxxxxx

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



Relevant Pages

  • Re: Command Execution Using Script - Similar to Windows Batch File-Like Script (Coding Help)
    ... very simple nmap command as listed below, ... If you want to make an executable script, ... "nmap 1.2.3.4" is a perfectly valid command, ... You can then try to execute the file either by calling ...
    (freebsd-questions)
  • Re: VBScript Help
    ... I think the issue is the launching that nmap through ... how far the script goes, ... wscript.echo "Label 1" ... I have tried running the command with the full path to nmap and actually ...
    (microsoft.public.scripting.vbscript)
  • Re: VBScript Help
    ... I think the issue is the launching that nmap ... the command shell is the problem. ... how far the script goes, ... wscript.echo "Label 1" ...
    (microsoft.public.scripting.vbscript)
  • Re: Need Help With Script
    ... The moment this line of the script executes, ... When you execute the command ... I tried your simplified syntax without usebackq or backquotes and the script ...
    (microsoft.public.windows.server.general)
  • Re: Batch Counter in For-Do loop
    ... > I have a batch file that executes a bunch of apps and counts the ... > I've stripped down the batch file to the following. ... The bracketted set of commands immediately following the "do" command are ... unexpected problems depending on what else your script does, ...
    (microsoft.public.win2000.cmdprompt.admin)