/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Passing commands to Windows exec

This is driving me nuts:

On a Windows box running abyss web server i am trying to pass a simple command to the system using “exec()”…have also tried using system(), etc.

I am trying to call ImageMagick to convert a photo The command works ok from the command prompt on the server itself, but I think PHP is not escaping spaces properly.

[code=php]
$tmp = “C:Program FilesAbyss Web Serverhtdocsimages\”.$file_basename.”.tiff”;
$jpg = “C:Program FilesAbyss Web Serverhtdocsimages\”.$file_basename.”.jpg”;

$convert = “convert “.$tmp.” “.$jpg;
exec($convert,$out);
print_r($out);
[/code]

I have tried several methods of escaping parts of the command but the same error keeps coming back:

[CODE]
Array ( [0] => Invalid Parameter – FilesAbyss )
[/CODE]

The error implies the first space in the arguement is being interpreted as parameter separator…Whats the deal? I’ve tried escaping spaces using ” “, “^ “, encapsulating the arguements in quotes, etc.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ZABIMar 01.2012 — [CODE]
$tmp = "C:\Program Files\Abyss Web Server\htdocsimages\".$file_basename.".tiff";
$jpg = "C:\Program Files\Abyss Web Server\htdocs\images\".$file_basename.".jpg";

OR

$tmp = "C:/Program Files/byss Web Server/htdocs/images/".$file_basename.".tiff";
$jpg = "C:/Program Files/Abyss Web Server/htdocs/images/".$file_basename.".jpg";

[/CODE]
Copy linkTweet thisAlerts:
@hastxauthorMar 01.2012 — No, tried those too. I finally got it to work using the relative path of the script using url style path instead of windows path...not sure I understand that one, but it finally worked. Windows is frusterating.

[code=php]
$tmp = "images/".$file_basename.".tiff";
$jpg = "images/".$file_basename.".jpg";
[/code]
×

Success!

Help @hastx spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...