Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-13-2002, 04:01 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
Shell commands from PHP

i need to run some shell commands in PHP to resize images... has anyone done this? i am using this


$cmd = "cd /usr2/hsphere/home/sdravers/sdravers.com/new/images/events
jpegtopnm temp.jpg > temp.ppm
pnmscale -xysize 600 600 temp.ppm > full.ppm
pnmscale -xysize 120 120 temp.ppm > thumb.ppm
pnmtojpeg thumb.ppm > $id_thumb.jpg
pnmtojpeg full.ppm > $id_full.jpg
rm *.ppm
rm temp.jpg
y";

shell_exec($cmd);

and i get the following error

Warning: Cannot execute using backquotes in safe mode in /usr2/hsphere/home/sdravers/sdravers.com/new/add_event.php on line 78


help?
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 08-13-2002, 05:04 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
i havent a clue except maybe this will help?

http://www.php.net/manual/en/functio...peshellcmd.php

what about making it it's own script like:

Code:
#script.php
#!/usr/bin/php
do all that stuff here
then: exec(script.php);

haven't tried it, .. i have executed files, but not with the shell_exec() function.
sde is offline   Reply With Quote
Old 08-13-2002, 10:36 PM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Its:
PHP Code:
#!/usr/bin/php -q
<?php
/*whatever php stuff */
?>
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-14-2002, 11:19 AM   #4 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
Hey guys,

This is a problem due to having safe_mode enabled. What you may want to do is use a CGI script to perform the selected tasks instead of invoking it directly from PHP. Since CGI is run via suexec, security isn't really an issue but PHP is not quite as easy to deal with due to Apache 1.3 limitations.

Alternatively, a CGI version of PHP can be used but you'll likely have to create a separate directory with your "unsafe" scripts and a .htaccess control file that looks like this:
Code:
AddType application/cgi-php php
Action application/cgi-php /usr/local/bin/php
Now each .php file within this directory will be executed via CGI/suexec, safely but without the safe_mode limitations. I hope that helps at least a little.

** EDIT **
I was wrong. It can be made to work using the above method, but .htaccess files use relative paths so the php binary has to be copied into your web space, presumably into cgi-bin as php.cgi (for clarity) and the "Action" part of the .htaccess file should read "Action application/cgi-php /cgi-bin/php.cgi" instead of what I wrote above. Sorry for the confusion!
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Comes of Age sde Code Newbie News 0 04-14-2004 11:41 AM
I need to learn PHP Nitro PHP 9 06-28-2003 11:24 AM
Php Vs. Asp sde PHP 6 06-06-2003 06:02 PM
PHP Command-Line Arguments? Antagony PHP 3 05-02-2003 12:26 PM


All times are GMT -8. The time now is 11:11 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting