using quotes in exec( ) or escapeshellcmd( )

From: LRW (deja_at_celticbear.com)
Date: 06/29/04


Date: 29 Jun 2004 13:21:57 -0700

I have a command I need to run in a shell:

/usr/bin/mogrify -size 180x180 -colors 256 -colorspace RGB +profile
"*" /usr/shipthumbs/*.tif

I've tried doing this:

$mog = "/usr/bin/mogrify -size 180x180 -colors 256 -colorspace RGB
+profile \"*\" /usr/shipthumbs/*.tif";
exec("$mog 2>&1", $output);

and

$mog = escapeshellcmd("/usr/bin/mogrify -size 180x180 -colors 256
-colorspace RGB +profile \"*\" /usr/shipthumbs/*.tif");
exec("$mog 2>&1", $output);

and

$mog = escapeshellcmd('/bin/bash -c "/usr/bin/mogrify -size 180x180
-colors 256 -colorspace RGB +profile "*" /usr/shipthumbs/*.tif'");
exec("$mog 2>&1", $output);

And no matter when I do, when that PHP script runs and I do a "ps aux"
I see the command line it's running always has the quotes that NEED to
be there ( "*" ) wrong.
either it's "\*" (yes I have the slash in the right place) or just *
without the quotes.

What's thr right way to formulate an exec() or an escapeshellcmd() so
that double quotes that HAVE to be sent to the shell get there?

Thanks!!
Liam



Relevant Pages

  • Re: Bash commands: maybe they want to drive us crazy?
    ... Bill Unruh wrote: ... single quotes would cause the find command to expand the * ... Which means that a shell command and the shell itself are two very different ...
    (comp.os.linux.misc)
  • Re: Bash commands: maybe they want to drive us crazy?
    ... > Bill Unruh wrote: ... > single quotes would cause the find command to expand the * ... > Which means that a shell command and the shell itself are two very different ...
    (comp.os.linux.misc)
  • Re: Background subprocess help?
    ... This description does not correspond to the command above. ... command is confusing because it uses quotes in a strange way. ... meant at the linguistic level and the inner quotes are shell quotes. ... d> processes and/or callbacks and 50+ lines of python code. ...
    (comp.lang.python)
  • Re: Using Shell command
    ... >From what I've been able to tell, Shell doesn't like Start. ... Single quotes wouldn't work, Paint didn't like them, so I had to double up ... The vbmaximizedfocus works on the command window, ... Start would just open another command window with the item in quotes as the ...
    (microsoft.public.access.modulesdaovba)
  • Re: Bash commands: maybe they want to drive us crazy?
    ... > single quotes would cause the find command to expand the * ... > The shell seems to expect a command inside back quotes (or back ticks, ... the single quotes turns the shell into parrot. ...
    (comp.os.linux.misc)