CURLOPT_FOLLOWLOCATION, open_basedir, and shell php?

I wrote a php-framework-based web application that utilizes CURL and CURLOPT_FOLLOWLACTION and it works great on my localhost. However, when i move it up to the client's shared webserver the open_basedir is set, but safe_mode is off, and i'm running into the error msg:

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when open_basedir is set in /home/user/public_html/myscript.php on line...

After doing some googling on this subject, it was suggested that you move the part of the php code that uses CURL into a php shell script and put it in the /tmp directory on the server, then inside your web application call the php shell script with this code:
$data = shell_exec('/tmp/myscript.php $first_arg $second_arg');

I gave this idea a shot but it does not seem to be sending the variables to the shell myscript.php and is returning part of the headers despite using the -q flag at the top of the myscript.php file, #!/usr/bin/php -q and errors out with:

X-Powered-By: PHP/5.2.9 Content-type: text/html  malformed

Is this because shell php or CLI php is different than web-type php? Or am i not calling the script right or have done something else wrong? I am open to suggestions.

The myscript.php that i'm trying to get to work looks like the following. Any suggestions on what i can do to get this to work:

#!/usr/bin/php -q
<?php
    $my_url = $argv[1];
    echo $my_url;
    $my_refer = $argv[2];
    echo $my_refer;

		$Debug=true;
		$ch=0;
		$ch = curl_init($url) or die(curl_error());
		$mycookie_file="/tmp/cookiefile.txt";
		
		// set a page referrer
		curl_setopt($ch, CURLOPT_REFERER, $refer);
		// set the url to fetch
		curl_setopt($ch, CURLOPT_URL,$url);
		// set the cookie in specified  file
		curl_setopt ($ch, CURLOPT_COOKIEJAR, $mycookie_file); 
		curl_setopt($ch, CURLOPT_POST, 1);
		// return the value instead of printing the response to browser
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		// give me the headers or not?
		curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch,CURLOPT_TIMEOUT,15);

		$data=curl_exec($ch) or die(curl_error());
		$info = curl_getinfo($ch);
		$valid = array(200, 302, 301);
		if (in_array($info['http_code'], $valid)) {
   			echo 'ok';
   			return $data;
		}
		
		echo curl_error($ch);
		
		// remember to always close the session and free all resources 
		curl_close($ch);
?>