1753725 Members
4467 Online
108799 Solutions
New Discussion юеВ

Re: Script question

 
SOLVED
Go to solution
Allanm
Super Advisor

Script question

Hi!

I have a piece of php code which makes a system call to curl command -

$system_string = "curl " . $url . " -d update=notupdated -d area=US -d -o outputfile;

Problem is that the URL variable now points to a diff URL with a different VIP but same URI.

I can run the curl from commandline and it works but not thru the script.

Can you guess what could have gone awry here?

Thanks,
Allan.
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script question

Hi Allan:

> Can you guess what could have gone awry here?

No, can you? Seriously, this looks like Perl. Hence:

$system_string = "curl " . $url . " -d update=notupdated -d area=US -d -o outputfile;

...is lacking a closing double quote.

Also, are you sure that '$url' has the value you think it does?

Also, if you call system() with this string, what is the return code you see?

Guessing is fun.

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: Script question

Although I have no PHP knowledge, I think that PHP's syntax was widely taken from Perl.

However, I suspect in the string concatenation which defines the variable $system_string that there is whitespace missing between the curl command and the URL, of course depending on the content of the variable $url.
So I would suggest rewriting the assignment like this, also repositioning the curl options to be in conformance with Unix command line tradition (though that might not be necessary for the curl command).
Also there seems to be a superfluous -d option in your assignment because no POST data follows it (see man curl).

$system_string = "curl -d update=notupdated -d area=US -o outputfile ".$url;

I assume that PHP like Perl has a system() function call to which the $system_string variable is supposed to be passed?

Madness, thy name is system administration