File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes run curl from a cgi script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "run curl from a cgi script" Watch "run curl from a cgi script" New topic

run curl from a cgi script

Howard Ralston
Ranch Hand

Joined: Jun 25, 2001
Posts: 105
Hi guys,
I am trying to run a perl script (runCurl.cgi) from my cgi-bin. In the program I simply want to pass parameters, create a string, and then run curl use the string. For example:
curl ""
I have tried to use this but get a syntax error:
syntax error at runCurl.cgi line 7, near "curl """
Execution of runCurl.cgi aborted due to compilation errors.
Here is what I have. I have not set up receipt of parameters yet just have it hard coded.

Any ideas on how to actually do this?
[ March 21, 2003: Message edited by: Howard Ralston ]

<a href="" target="_blank" rel="nofollow">Free local coupons</a>
Donal Lynch

Joined: May 02, 2002
Posts: 15
I'm not familiar with curl, but assuming that it's a separate program and not a Perl function, you can get its output with open FILEHANDLE,'command|':

Since this is interpreted by something like a shell, you might have to escape out the ampersands and question marks; also be aware of the security implications of substituting parameters.
[ March 22, 2003: Message edited by: Donal Lynch ]
I agree. Here's the link:
subject: run curl from a cgi script
jQuery in Action, 3rd edition