Connecting Tech Pros Worldwide Forums | Help | Site Map

un php script and excpect an answer

pas805@gmail.com
Guest
 
Posts: n/a
#1: Sep 13 '05
I have a PHP page that I would like to run with cron but that's not the
problem. My problem come when I run my script throw my browser the
script runs properly but when I try to run the script using either php,
lynx or wget the script starts but once the request is made the script
stops running. EX.: I get a client from my database and send a request
to my billing company to get the status of is invoice.

So basically the script never comes back with an answer.


Steve
Guest
 
Posts: n/a
#2: Sep 13 '05

re: un php script and excpect an answer


[color=blue]
> My problem come when I run my script throw my browser the
> script runs properly but when I try to run the script using either php,
> lynx or wget the script starts but once the request is made the script
> stops running.[/color]

Does your page depend on javascript in any way? This would not be
executed by cron, wget, or command line PHP (not sure about lynx).

---
Steve

pas805@gmail.com
Guest
 
Posts: n/a
#3: Sep 14 '05

re: un php script and excpect an answer


> My problem come when I run my script throw my browser the[color=blue]
> script runs properly but when I try to run the script using either php,
> lynx or wget the script starts but once the request is made the script
> stops running.[/color]

No it's simply PHP

Steve
Guest
 
Posts: n/a
#4: Sep 14 '05

re: un php script and excpect an answer


[color=blue]
> My problem come when I run my script throw my browser the
> script runs properly but when I try to run the script using either php,
> lynx or wget the script starts but once the request is made the script
> stops running.[/color]

Then, you should create the smallest possible script that reproduces
the problem, and then post it here.

By that I mean that you should make a copy of your faulty script, and
progressively remove code from it until it no longer fails in the way
you describe. The last thing you take out will probably give you a clue
about the cause of the problem. If it doesn't, put it back in and post
the short script here (and tell us what the last thing was!)

---
Steve

pas805@gmail.com
Guest
 
Posts: n/a
#5: Sep 14 '05

re: un php script and excpect an answer


> Then, you should create the smallest possible script that reproduces[color=blue]
> the problem, and then post it here.[/color]
[color=blue]
> By that I mean that you should make a copy of your faulty script, and
> progressively remove code from it until it no longer fails in the way
> you describe. The last thing you take out will probably give you a clue
> about the cause of the problem. If it doesn't, put it back in and post
> the short script here (and tell us what the last thing was!)[/color]

For security reasons I cannot post my script. But my script is in no
way faulty has it run like it should throw a browser but like I said
before when I execute it in my browser it runs with no problem and has
soon has I try to execute it throw the command line the script starts,
sends the request and ends and will not continue but it ends with no
error. So I have no clue why do I have to specify in the command line
that it's a recursive script or ...???

I can probably do an example here (this is just a brief example to help
you guys):

// receives the request from the billing company and updates the
// invoice status of the client but for the first execution there is
// nothing so does not go in the if
If($_GET['status']){
// execute a DB operation to set the invoice status
}

// verify that there is a next client and fetch is it
$value = 'customers_id='.$customers_id.'&'.
'invoiceType='.$inv_type.'&'.....

//Sends a request to the billing company
redirect('https://portal?'.$value);

// The script has ended

Steve
Guest
 
Posts: n/a
#6: Sep 14 '05

re: un php script and excpect an answer


[color=blue]
> redirect('https://portal?'.$value);[/color]

This is the source of the problem. lynx and wget will both have
problems following the redirection although the rest of the script will
have been executed.

Why not use PHP instead? 8-) fopen() will follow redirections...


<?php
$file = fopen( "http://www.php.net/fopen", "r" );
if( !$file )
{
print "fopen() failed";
exit;
}
while( !feof( $file ) )
{
$html = fgets( $file, 1024 );
print $html;
}
fclose( $file );
?>


---
Steve

pas805@gmail.com
Guest
 
Posts: n/a
#7: Sep 14 '05

re: un php script and excpect an answer


Steve so you want me to create a script that open's my other script and
execute it right???

Steve
Guest
 
Posts: n/a
#8: Sep 15 '05

re: un php script and excpect an answer


[color=blue]
> Steve so you want me to create a script that open's my other script and
> execute it right???[/color]

That might be one way round your problem. Going back to what you are
trying to do - execute a PHP script via cron - the limitations of wget
and lynx prevent you from executing it directly. Assuming you can't
remodel your script to avoid the redirection, instead you have an
intermediary script call the main script from cron:

wget http://www.example.com/myscriptcaller.php

myscriptcaller.php is the simple fopen()/fread()/fclose() script from
earlier in this thread, set to call your main script.

---
Steve

pas805@gmail.com
Guest
 
Posts: n/a
#9: Sep 17 '05

re: un php script and excpect an answer


I actually tried it but the fopen has to point to the physical
I tried it but the fopen has to point to the physical file on the
server like "/www/html/myscript.php" because if I put the url to the
file it gives me an error and if I put the physical path to the file
"/www/html/myscript.php" it simply print out the lines and that's it.



Steve wrote:[color=blue][color=green]
> > Steve so you want me to create a script that open's my other script and
> > execute it right???[/color]
>
> That might be one way round your problem. Going back to what you are
> trying to do - execute a PHP script via cron - the limitations of wget
> and lynx prevent you from executing it directly. Assuming you can't
> remodel your script to avoid the redirection, instead you have an
> intermediary script call the main script from cron:
>
> wget http://www.example.com/myscriptcaller.php
>
> myscriptcaller.php is the simple fopen()/fread()/fclose() script from
> earlier in this thread, set to call your main script.
>
> ---
> Steve[/color]

Closed Thread