Re: exec won't pass arg with spaces

From: Date: Fri, 30 Jan 2004 23:59:12 +0000
Subject: Re: exec won't pass arg with spaces
References: 1 2  Groups: php.general php.general 
Request: Send a blank email to php-general+get-176421@lists.php.net to get a copy of this message
You where completely right, thanks so much for this tip. I didn't try the "this\ is\ the\ file" approach, but I'll do it and let you know if it worked. Raúl Michal Migurski wrote:
Sample code:
       exec("$imagemagickPath/convert -geometry " .
       "{$thumbnail_width}x{$thumbnail_height} " .
       "$images_dir/$filename $images_dir/tb_$filename");
where filename could be: /var/www/html/images/SPIN CoreRT1 to EX-JF1 (cw - kpi - KPI Performance Report(Weekly).png
More quotes! :) The shell delimits tokens with whitespace, so you'd need to escape that whitespace, or quote it, like so (untested): exec(sprintf('%s/concert -geometry %dx%d "%s/%s" "%s/tb_%s"',
	             $imagemagickPath,
	             $thumbnail_width, $thumbnail_height,
	             $images_dir, $filename,
	             $images_dir, $filename));
Note the extra quotes around the two filepaths. --------------------------------------------------------------------- michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html


« previous php.general (#176421) next »