curl doesn't work in browser


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting curl doesn't work in browser
# 1  
Old 06-04-2010
curl doesn't work in browser

Hi

I need once again you help guys,
I have a php script that should call and url on the local-server, when i call the script from the browser it just prints the $str and it doesn't call the url, but when i execute the script from the shell (php sentdata.php) it works.
I checked the apache logs and there are not errors.

My server details are:
PHP 5.3.2 (cli) (built: Apr 27 2010 17:55:02)
Zend Engine v2.3.0
Linux xxxxxxxxxxx 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 i686 i386 GNU/Linux
Server version: Apache/2.2.15 (Unix)
Server built: Apr 10 2010 11:21:07


PHP Code:
<?php
$user     
urlencode('user');
$password urlencode('pass');
$var1  urlencode('zzzzzz');
$var2 urlencode('yyyyyy');
$var3 urlencode('xxxxx');




$str"?username=".$user."&password=".$password."&var1=".$var1."&var2=".$var2."&var3=".$var3;

print 
$str;

 
$ch=curl_init();
 
curl_setopt($ch,CURLOPT_URL,'http://localhost:12812/cgi-bin/incomming'.$str);
 
curl_exec($ch);
 
curl_close($ch);
?>
Thanks in advance
# 2  
Old 06-04-2010
Try checking the return values of curl_setopt, curl_exec, etc. They may tell you what is or isn't happening.
# 3  
Old 06-04-2010
...or use the curl_error($ch) function to return any possible error.
# 4  
Old 06-07-2010
I tried that but it is still the same on shell the scripts works but not when i run it from the browser.

this is the output from my script it is the same as in the shell.

HTML Code:
Array
(
    [url] => http://localhost:12812/cgi-bin/incomming?username=user&password=pass&var1=zzzzz&var2=yyyyyy&var3=xxxxx                                                      
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => 0
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0
    [namelookup_time] => 0
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

)


cURL error number:0

cURL error:
# 5  
Old 06-07-2010
Quote:
Originally Posted by tafil
I tried that but it is still the same on shell the scripts works but not when i run it from the browser.
Nothing returns any error messages in the browser? What were the return values of the various functions I reccomended checking the output of?
# 6  
Old 06-08-2010
Its strange for my why it is not working in the browser, it works when i execute it from the shell, this means that the script is okay.
Is it possible that this is more related to the apache permissions?
# 7  
Old 06-08-2010
There must be an warning/error message somewhere. Make sure the PHP error reporting is set to a appropriate value like E_ALL:

PHP Code:
error_reporting(E_ALL); 
Add the http return header switch to curl:

PHP Code:
curl_setopt($chCURLOPT_HEADERTRUE);
echo 
curl_error($ch); 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Curl doesn't return csv file

Hi every body, I'm getting a trouble with my script , it's supposed to return a csv file . /usr/bin/curl -LS -D- -X GET -H "Authorization:Basic $password" -H 'Content-Type: text/csv' -L -o $OUTPUT_FILENAME $url; But I get an empty file with : {"ErrorCode":1001,"ErrorMessage":"Incorrect login... (0 Replies)
Discussion started by: beautymind
0 Replies

2. Shell Programming and Scripting

Script containing Curl doesn't run with crontab

Hello I have a problem with the crontab command when I run a code containing Curl on the command line it runs without fail but as soon as I program it with crontab it executes everything except the curl returns fail thank you for helping me to resolve this problem because since Monday I look... (14 Replies)
Discussion started by: beautymind
14 Replies

3. Shell Programming and Scripting

-ne 0 doesn't work -le does

Hi, I am using korn shell. until ] do echo "\$# = " $# echo "$1" shift done To the above script, I passed 2 parameters and the program control doesn't enter inside "until" loop. If I change it to until ] then it does work. Why numeric comparison is not working with -ne and works... (3 Replies)
Discussion started by: ab_2010
3 Replies

4. UNIX for Dummies Questions & Answers

Why doesn't this work?

find . -name "05_scripts" -type d -exec mv -f {}/'*.aep\ Logs' {}/.LogFiles \; Returns this failure: mv: rename ./019_0120_WS_WH_gate_insideTEST/05_scripts/*.aep\ Logs to ./019_0120_WS_WH_gate_insideTEST/05_scripts/.LogFiles/*.aep\ Logs: No such file or directory I don't know why it's trying... (4 Replies)
Discussion started by: scribling
4 Replies

5. UNIX for Dummies Questions & Answers

useradd doesn't work! why??

# uname -a Linux localhost.localdomain 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux # useradd 4141421248 useradd: invalid user name '4141421248' why??? (6 Replies)
Discussion started by: cqlouis
6 Replies

6. Shell Programming and Scripting

What to do when mtime doesn't work?

I have a folder that I need to search for new files and copy on the latest. I've been using "-mtime -1" in my command line but it doesn't seem to work. I've been meaning to fine a different script because files are dropped into the folder all day long and because of the -mtime, I've only be... (19 Replies)
Discussion started by: bbbngowc
19 Replies

7. Shell Programming and Scripting

Awk: Can anyone tell me why this doesn't work?

If there exists a field in stdin, print it, otherwise, print hello..... These print nothing: cat /dev/null | awk '{if ( length > 0 ) print $1; else print "hello"}' cat /dev/null | awk '{if ( $1 ) print $1; else print "hello"}'But the scripts work if I run them directly in a terminal: ... (8 Replies)
Discussion started by: ksheller
8 Replies

8. UNIX for Dummies Questions & Answers

lp -o <option> doesn't work

why lp -o <option> doesn't work on my SCO Unix. (4 Replies)
Discussion started by: wendyz
4 Replies

9. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

10. Shell Programming and Scripting

Why doesn't this work?

cat .servers | while read LINE; do ssh jason@$LINE $1 done exit 1 ./command.ksh "ls -l ~jason" Why does this ONLY iterate on the first server in the list? It's not doing the command on all the servers in the list, what am I missing? Thanks! JP (2 Replies)
Discussion started by: jpeery
2 Replies
Login or Register to Ask a Question