Note that there are some explanatory texts on larger screens.

plurals
  1. POCron job has a different output then running a script in the browser
    primarykey
    data
    text
    <p>I'm running the following code on my server, the script works fine in the browser but when i try it in a cronjob or through shell logged in as root i get a totally different output.</p> <p>output through the browser:</p> <ul> <li>logs in and gets the page i want</li> </ul> <p>output through shell / cron:</p> <ul> <li>doesn't seem to login, but gets the contents of the page redirecting me back to the login page.</li> </ul> <p>i'm using red hat linux 5</p> <pre><code>&lt;?php $url = "http://www.domain.com/shopper_lookup.asp"; // the url where to send the request $fields_send = 'shopper_username=USERNAME&amp;shopper_password=PASSWORD&amp;Validate=1'; $agent = "Opera/9.63 (Windows NT 5.1; U; en-GB) Presto/2.1.1"; $reffer = "http://www.domain.com/login.html"; $cookie_file_path = "/var/www/vhosts/domain.co.uk/httpdocs/store/cookie"; // Cookie File Path with CHMOD 777 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_send); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $reffer); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); $result_source = curl_exec($ch); var_dump($ch); echo $result_source; $url = "http://www.domain.com/receipt.asp?ms=&amp;order_id=ordernumber"; // the url where to send the request $agent = "Opera/9.63 (Windows NT 5.1; U; en-GB) Presto/2.1.1"; $reffer = "http://www.domain.com/contents.asp?ms="; $cookie_file_path = "/var/www/vhosts/domain.co.uk/httpdocs/store/cookie"; // Cookie File Path with CHMOD 777 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_GET, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $reffer); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); $result_source = curl_exec($ch); echo $result_source; // Print the result page ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload