RE: [PHP] cURL in an exec() . more

2002-07-03 Thread jay . blanchard

[snip]
As a matter of fact, when viewing the source (which should display properly
if word wrap is off in Notepad) the line appears to be broken up. I have an
idea...write the line to a file then open the file and get the line for
exec()...blabbering now, must go...
[/snip]

I have fixed many things and had many great suggestions pointed my way, I
appreciate all of it! So to state the problem in the light of this new day
here is what I have;

From the command line this works perfectly;
curl -d name=mynamepassword=mypasswordbtnsubmit=submit -s -o
cdrlist.html https://theserver.com/download/list.html

Using exec() (or shell_exec(), or others in the family) like this;

exec(curl -d \name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o
cdrlist.html https://theserver.com/download/list.html;);

does not work. I have made sure that the output of the exec() is all on one
line through many tests. I have placed the command line arguements in
variables and re-done the exec() call as many ways as I can think of. Is
anyone aware of any problems with exec() that may be causing this behavior?
Any insight would be grandly appreciated.

Thanks!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] cURL in an exec() . more

2002-07-03 Thread Jay Blanchard

OK, here is where I am (between handling other pre-holiday/long weekend
processese here);

I have the PHP script create a shell script containing the needed code for
the cURL process. Of course the shell script will execute from the command
line with me as 'root'. But the exec() that calls the shell script will not
execute the script because of improper permissions. (Has to do with the
permissions on the topmost directory for where the file lives, changing that
could be dangerous from a security standpoint).

So I have tried to change those (I am on a Linux box) via the PHP, no luck.
It will let me chmod the shell script via the PHP script. So I tried to move
the script to /usr/local/bin;

rename(getlist.sh, /usr/local/bin/getlist.sh); Permission denied
exec(mv getlist.sh /usr/local/bin/getlist.sh); Permissiion denied
exec(cp getlist.sh /usr/local/bin/getlist.sh); Permissiion denied

I am looking into posix_setuid() to change the permissions for the time
needed, but I've a feeling, after a couple of tests, that this is not going
to be the way to do this either.

I wish permissions in Linux were more straigtforward. Anyone have an idea
how to do this with opening the server wide? Thanks for all your help.

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] cURL in an exec() . more

2002-07-03 Thread B i g D o g

Check out setuid and sticky bits for the file permissions.

Remember that if you are running php under apache and you try the exec with
a command php is running with apaches permissions.  So apache needs to be
able to run what ever you are trying to run with the exec command.

B i g D o g


- Original Message -
From: Jay Blanchard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 03, 2002 8:49 AM
Subject: RE: [PHP] cURL in an exec() . more


 OK, here is where I am (between handling other pre-holiday/long weekend
 processese here);

 I have the PHP script create a shell script containing the needed code for
 the cURL process. Of course the shell script will execute from the command
 line with me as 'root'. But the exec() that calls the shell script will
not
 execute the script because of improper permissions. (Has to do with the
 permissions on the topmost directory for where the file lives, changing
that
 could be dangerous from a security standpoint).

 So I have tried to change those (I am on a Linux box) via the PHP, no
luck.
 It will let me chmod the shell script via the PHP script. So I tried to
move
 the script to /usr/local/bin;

 rename(getlist.sh, /usr/local/bin/getlist.sh); Permission denied
 exec(mv getlist.sh /usr/local/bin/getlist.sh); Permissiion denied
 exec(cp getlist.sh /usr/local/bin/getlist.sh); Permissiion denied

 I am looking into posix_setuid() to change the permissions for the time
 needed, but I've a feeling, after a couple of tests, that this is not
going
 to be the way to do this either.

 I wish permissions in Linux were more straigtforward. Anyone have an idea
 how to do this with opening the server wide? Thanks for all your help.

 Jay



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] cURL in an exec() . more

2002-07-03 Thread Scott Fletcher

Ah!  I know what you're feeling about Linux.  I had that problem using PHP
and text editing software (for programming) with Caldera, like ftp timeout,
security, file path, etc.  It become too much for me, so I junked it and
went back to AIX.  I haven't tried it on Red Hat but I can easily turned off
hte ftp timeout, etc. from there.  Haven't tried PHP stuffs on Red Hat.

FletchSOD
Jay Blanchard [EMAIL PROTECTED] wrote in message
002701c222a0$c958ffc0$8102a8c0@niigziuo4ohhdt">news:002701c222a0$c958ffc0$8102a8c0@niigziuo4ohhdt...
 OK, here is where I am (between handling other pre-holiday/long weekend
 processese here);

 I have the PHP script create a shell script containing the needed code for
 the cURL process. Of course the shell script will execute from the command
 line with me as 'root'. But the exec() that calls the shell script will
not
 execute the script because of improper permissions. (Has to do with the
 permissions on the topmost directory for where the file lives, changing
that
 could be dangerous from a security standpoint).

 So I have tried to change those (I am on a Linux box) via the PHP, no
luck.
 It will let me chmod the shell script via the PHP script. So I tried to
move
 the script to /usr/local/bin;

 rename(getlist.sh, /usr/local/bin/getlist.sh); Permission denied
 exec(mv getlist.sh /usr/local/bin/getlist.sh); Permissiion denied
 exec(cp getlist.sh /usr/local/bin/getlist.sh); Permissiion denied

 I am looking into posix_setuid() to change the permissions for the time
 needed, but I've a feeling, after a couple of tests, that this is not
going
 to be the way to do this either.

 I wish permissions in Linux were more straigtforward. Anyone have an idea
 how to do this with opening the server wide? Thanks for all your help.

 Jay





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] cURL in an exec() . more

2002-07-03 Thread Jason Wong

On Wednesday 03 July 2002 22:49, Jay Blanchard wrote:

 I have the PHP script create a shell script containing the needed code for
 the cURL process. Of course the shell script will execute from the command
 line with me as 'root'. But the exec() that calls the shell script will not
 execute the script because of improper permissions. (Has to do with the
 permissions on the topmost directory for where the file lives, changing
 that could be dangerous from a security standpoint).

I'm not sure I understand you. You have a php script which creates a 
shell-script. Then you have a php script which exec('shell-script')? Assuming 
that the php script is run by the same user throughout then I don't see why 
it cannot exec your shell-script. Perhaps you can elaborate.

 So I have tried to change those (I am on a Linux box) via the PHP, no luck.
 It will let me chmod the shell script via the PHP script. 

OK ...

 So I tried to
 move the script to /usr/local/bin;

so why do you need to move it? Why can't you exec() it where it is?

Try hand writing a script then exec() it from php.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Alcohol, hashish, prussic acid, strychnine are weak dilutions. The surest
poison is time.
-- Emerson, Society and Solitude
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re [PHP] cURL in an exec() . more. SOLVED

2002-07-03 Thread Jay Blanchard

It's always the smallest things that will get you, I should be slapped
(preferably by a good looking woman) :) 

exec was not broken
the permissions don't have to be mucked with
ownership and group can be left alone
this should be stamped on the forehead of each and every PHP developer

USE FULL PATHS!

$bash = #!/bin/sh;
$curl = /usr/local/bin/curl -d
\name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o cdrlist.html
https://theserver.com/download/list.html;;
$sh = fopen(/var/www/htdocs/rcr/getlist.sh, w+);
   fputs($sh, $bash.\n\n);
   fputs($sh, $curl);
fclose($sh);
chmod(/var/www/htdocs/rcr/getlist.sh, 0755);
exec(/var/www/htdocs/rcr/getlist.sh);

This solved all of the problems. I did the full paths thing during the
process of elimination, to remove all doubt about the code. This will make
sure that the script can be found and executed.

On another note;

Had I done this with exec and the cURL statement earlier it would have
worked as well. But I think that i am going to keep it this way as it will
hopefully make the code clearer. I will have to write more cURL statements
later in the script and I can then assemble shell scripts as needed.

Thanks for all of your help...

Jay




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Re [PHP] cURL in an exec() . more. SOLVED

2002-07-03 Thread Scott Fletcher

Ha ha!  Just what I mentioned from above.  FULL PATH!  :-)  FletchSOD

Jay Blanchard [EMAIL PROTECTED] wrote in message
003201c222ac$9760ad90$8102a8c0@niigziuo4ohhdt">news:003201c222ac$9760ad90$8102a8c0@niigziuo4ohhdt...
 It's always the smallest things that will get you, I should be slapped
 (preferably by a good looking woman) :) 

 exec was not broken
 the permissions don't have to be mucked with
 ownership and group can be left alone
 this should be stamped on the forehead of each and every PHP developer

 USE FULL PATHS!

 $bash = #!/bin/sh;
 $curl = /usr/local/bin/curl -d
 \name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o cdrlist.html
 https://theserver.com/download/list.html;;
 $sh = fopen(/var/www/htdocs/rcr/getlist.sh, w+);
fputs($sh, $bash.\n\n);
fputs($sh, $curl);
 fclose($sh);
 chmod(/var/www/htdocs/rcr/getlist.sh, 0755);
 exec(/var/www/htdocs/rcr/getlist.sh);

 This solved all of the problems. I did the full paths thing during the
 process of elimination, to remove all doubt about the code. This will make
 sure that the script can be found and executed.

 On another note;

 Had I done this with exec and the cURL statement earlier it would have
 worked as well. But I think that i am going to keep it this way as it will
 hopefully make the code clearer. I will have to write more cURL statements
 later in the script and I can then assemble shell scripts as needed.

 Thanks for all of your help...

 Jay






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Re [PHP] cURL in an exec() . more. SOLVED

2002-07-03 Thread Scott Fletcher

:-)  I went through the same thing the first time!  Never again!  I just
pray and hope that I don't forget the next time!

Scott Fletcher [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ha ha!  Just what I mentioned from above.  FULL PATH!  :-)  FletchSOD

 Jay Blanchard [EMAIL PROTECTED] wrote in message
 003201c222ac$9760ad90$8102a8c0@niigziuo4ohhdt">news:003201c222ac$9760ad90$8102a8c0@niigziuo4ohhdt...
  It's always the smallest things that will get you, I should be slapped
  (preferably by a good looking woman) :) 
 
  exec was not broken
  the permissions don't have to be mucked with
  ownership and group can be left alone
  this should be stamped on the forehead of each and every PHP developer
 
  USE FULL PATHS!
 
  $bash = #!/bin/sh;
  $curl = /usr/local/bin/curl -d
  \name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o cdrlist.html
  https://theserver.com/download/list.html;;
  $sh = fopen(/var/www/htdocs/rcr/getlist.sh, w+);
 fputs($sh, $bash.\n\n);
 fputs($sh, $curl);
  fclose($sh);
  chmod(/var/www/htdocs/rcr/getlist.sh, 0755);
  exec(/var/www/htdocs/rcr/getlist.sh);
 
  This solved all of the problems. I did the full paths thing during the
  process of elimination, to remove all doubt about the code. This will
make
  sure that the script can be found and executed.
 
  On another note;
 
  Had I done this with exec and the cURL statement earlier it would have
  worked as well. But I think that i am going to keep it this way as it
will
  hopefully make the code clearer. I will have to write more cURL
statements
  later in the script and I can then assemble shell scripts as needed.
 
  Thanks for all of your help...
 
  Jay
 
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] cURL in an exec() MORE...

2002-07-01 Thread Jay Blanchard

[snip]
Thanks Jason, I fixed that and still does not work. So I am trying this;
$curlline(curl -d
\name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o .$listline.
https://theserver.com/download/.$listline.;);
print($curlline); this looks fine
exec($curline);
[/snip]

The cURL statement has to be on one line, when I view the source the
statement appears to be broken up, i.e.
curl -d name=mynamepassword=mypasswordbtnsubmit=submit -s -o
2002060704.zip
 https://theserver/download/2002060704.zip

OK, so how do I keep a long line from breaking up without inserting special
characters? Maybe this why cURL is failing.

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] cURL in an exec() MORE...

2002-07-01 Thread Jason Wong

On Monday 01 July 2002 23:25, Jay Blanchard wrote:
 [snip]
 Thanks Jason, I fixed that and still does not work. So I am trying this;
 $curlline(curl -d
 \name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o .$listline.
 https://theserver.com/download/.$listline.;);
 print($curlline); this looks fine
 exec($curline);
 [/snip]

 The cURL statement has to be on one line, when I view the source the
 statement appears to be broken up, i.e.
 curl -d name=mynamepassword=mypasswordbtnsubmit=submit -s -o
 2002060704.zip
  https://theserver/download/2002060704.zip

 OK, so how do I keep a long line from breaking up without inserting special
 characters? Maybe this why cURL is failing.

Is the line in which you are assigning $curlline, all on one line? If not, 
make it so.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Conquering Russia should be done steppe by steppe.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] cURL in an exec() MORE...

2002-07-01 Thread Jay Blanchard

Yes it is...a, well. Time to compile PHP with cURL I guess. Thanks!

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 1:46 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] cURL in an exec() MORE...


On Monday 01 July 2002 23:25, Jay Blanchard wrote:
 [snip]
 Thanks Jason, I fixed that and still does not work. So I am trying this;
 $curlline(curl -d
 \name=mynamepassword=mypasswordbtnsubmit=submit\ -s -o .$listline.
 https://theserver.com/download/.$listline.;);
 print($curlline); this looks fine
 exec($curline);
 [/snip]

 The cURL statement has to be on one line, when I view the source the
 statement appears to be broken up, i.e.
 curl -d name=mynamepassword=mypasswordbtnsubmit=submit -s -o
 2002060704.zip
  https://theserver/download/2002060704.zip

 OK, so how do I keep a long line from breaking up without inserting
special
 characters? Maybe this why cURL is failing.

Is the line in which you are assigning $curlline, all on one line? If not,
make it so.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Conquering Russia should be done steppe by steppe.
*/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php