plsh icon indicating copy to clipboard operation
plsh copied to clipboard

curl command execute within plsh

Open walpino opened this issue 9 years ago • 3 comments

i want to execute curl from plsh

the procedure looks like

!/....

curl "$1"

and $1 looks like

'https://.....ewad.json' -v -X POST --data-urlencode 'address=fdfdf 38' --insecure --data-urlencode 'size=65' --data-urlencode 'hash=47b51e9dd1c6a833a7f3effe2ee9dc997632' --data-urlencode 'action=insert_ad' --data-urlencode 'region=14' --data-urlencode 'zipcode=3012' --data-urlencode 'app_id=homegate' --data-urlencode 'phone=07382' --data-urlencode '[email protected]' --data-urlencode 'body=Beautiful unfu' --data-urlencode 'phone_hidden=0' --data-urlencode 'price=1455' --data-urlencode 'category=1020' --data-urlencode 'rooms=4' --data-urlencode 'area=92' --data-urlencode 'company_ad=1' --data-urlencode 'lang=de' --data-urlencode 'name= ' --data-urlencode 'subject=2.5 room Apartment for rent' --data-urlencode 'no_licenseplate=1' --data-urlencode 'type=u' --data-urlencode 'store_id=49' --data-urlencode 'import=1' --data-urlencode 'external_ad_id=103466419'

the return value is curl(3) illegal character hmm but

if I execute this on the prompt everything works fine

do you have a hint whats wrong with this?

thanks

walpino avatar Jul 13 '16 12:07 walpino

Please show the exact function definition (CREATE FUNCTION ...).

petere avatar Jul 15 '16 05:07 petere

just a simple example

CREATE OR REPLACE FUNCTION query (x int) RETURNS text LANGUAGE plsh AS $$ #!/bin/sh /usr/bin/curl www.zkb.ch > /tmp/a.html /usr/bin/wget www.zkb.ch > /tmp/a.html $$;

the curl throws an error the wget works

if I'm doing this on the prompt the curl works fine too

walpino avatar Jul 15 '16 09:07 walpino

And what is your output?

You probably have to run curl with -s and wget with -q or similar, because plsh will interpret any output to stderr as failure. Other than that, your example works for me.

petere avatar Aug 09 '16 13:08 petere