SysExpert
asked on
Perl issue with @ in backticks for curl
I have a perl script that calls a curl command via backticks.
Because of the locked down environment I work in, I can not add any modules to the basic perl install ( 5.05 on most or 5.8.8 on the newest machines).
I have a problem with the @ in a curl command that allows input from a file: curl -d@filename
perl compalins that :
Can't use string ("home/xymon/server/ext/ch eck_webl") as an ARRAY ref while "strict refs" in use at ./xy_weblogic_chk.pl line 155.
`$CURL --connect-timeout 5 -m 15 -d@$XML_FILE http://$opt_IP/middleware 2>&1 | grep "/result" > $infile` ;
this cmmand works fine in a shell script
How do I escape or fix the command to get it to work in backticks or other solution.
Thanks in advance.
Because of the locked down environment I work in, I can not add any modules to the basic perl install ( 5.05 on most or 5.8.8 on the newest machines).
I have a problem with the @ in a curl command that allows input from a file: curl -d@filename
perl compalins that :
Can't use string ("home/xymon/server/ext/ch
`$CURL --connect-timeout 5 -m 15 -d@$XML_FILE http://$opt_IP/middleware 2>&1 | grep "/result" > $infile` ;
this cmmand works fine in a shell script
How do I escape or fix the command to get it to work in backticks or other solution.
Thanks in advance.
ASKER
That messes up the curl command
curl: (7) Failed to connect to 0.0.0.1: Invalid argument
curl: (7) Failed to connect to 0.0.0.1: Invalid argument
Strange. \ is a valid escape char in perl.
You could try single quotes, but that's just a guess:
`$CURL --connect-timeout 5 -m 15 -d '@'$XML_FILE http://$opt_IP/middleware 2>&1 | grep "/result" > $infile` ;
You could try single quotes, but that's just a guess:
`$CURL --connect-timeout 5 -m 15 -d '@'$XML_FILE http://$opt_IP/middleware 2>&1 | grep "/result" > $infile` ;
What would the curl command be if you gave it directly instead of from perl?
Also, what is in $opt_IP?
Also, what is in $opt_IP?
Better use perl module instead of external program.
http://curl.haxx.se/libcurl/perl/easy.pm.html
http://curl.haxx.se/libcurl/perl/easy.pm.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
`$CURL --connect-timeout 5 -m 15 -d\@$XML_FILE http://$opt_IP/middleware 2>&1 | grep "/result" > $infile` ;