![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: shells, shell_exec |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] Shell execution I need some help with executing a shell using PHP. The shell is in the following path: c:\tools\bin\ogr.exe I have read that <?php $cmd = command string ; shell_exec($cmd); ?> will di the trick but how do I get this function to execute the shell in the above path?? Sarel |
| |
| ||||
| Quote:
I have not done this before but wouldn't the command string be the path? So: PHP Code: __________________ ![]() Great looking text - by just typing into a box you can create great looking text for your msn names, myspace, bebo, netlog, facebook and more Last edited by Lee : 06-25-2008 at 10:19 AM. |
| The Following User Says Thank You to Lee For This Useful Post: | ||
sarel (06-27-2008) | ||
| ||||
| Good to here you got it going then, maybe you could post up how you did it so someone reading this thread in the future knows ![]() __________________ ![]() Great looking text - by just typing into a box you can create great looking text for your msn names, myspace, bebo, netlog, facebook and more |
| |||
| Ok the shell exec was relative easy, I have a problem with placing in variables so that the shell commands can be dynamic or user driven. such as the following: Code: <?php
$output = shell_exec('C:/FWTools2.2.1/bin/ogr2ogr -f "$filetype" c:/mygisdata/$postgislayer.$file_ext PG:"host=localhost user=postgres dbname=mdssdata password=database" "$postgislayer" ');
echo "<pre>$output</pre>";
?> the echo doesn't seem to "echo" the the variables in the $output string. I think it might be the way I use quotes around the variables, the quotes are required on the shell command. Hope someone can help. Thanks Sarel ![]() Last edited by sarel : 06-26-2008 at 07:45 AM. |
| ||||
| You need to put . before and after like so: Code: echo "<pre>" . $output . "</pre>"; |
| The Following User Says Thank You to MrPickle For This Useful Post: | ||
sarel (06-27-2008) | ||
| |||
![]() ![]() No sorry that didn't work but no worries I got it working, it was those devilish quotes as expected. so double quotes are required for the shell command and to get them attached on the variables when echo-ing is done by doing so: \"$variable\" so place the entire string into $cmd then echo the shell+$cmd like so: echo "<pre>".shell_exec($cmd)."</pre>"; yahooooooooooooooooooooooo aaaaaaaaaaaaggghhhh |
![]() |
| Thread Tools | |
| Display Modes | |
| |