cancel
Showing results for 
Search instead for 
Did you mean: 

Can't execute javascript using curl with cron

gsauvage
Champ in-the-making
Champ in-the-making

Hello,

I'm running a Alfresco EE 4.1.1.3 (old).

I often run some js script on admin console, and sometimes I do write shell script for executing those js script (using curl) and I launch it from my VM. I wanted to schedule one script for some reason and so I decided to execute the shell script from cron. When I execute the script from shell, it is executed, I get the response and see the result on alfresco (let's say in the script I juste move some file from a directory to another). But when the script is executed from cron, I get no response from alfresco side (the cron is triggered, shell is executed but curl does not answer the output and don't do change on alfresco, so the js script is not applied).

The shell script command for executing the script is as such :

curl $URL_JS_CONSOLE_SHARE \
-H 'Auth-User: admin' \
-H 'Content-Type: application/json' \
-H 'Connection: keep-alive' \
--data-binary "{'script':$SCRIPT,'template':'','spaceNodeRef':'$SPACENODEREF','transaction':'readwrite','runas':'admin','urlargs':'','documentNodeRef':''}" --compressed \
-o $response_file_name

javascript file is as such:

logger.warn("test")

Output from shell launched by hand :

{"result":[],"renderedTemplate":"","scriptPerf":"7","spacePath":"/Espace racine","printOutput":["test"],"spaceNodeRef":"workspace://SpacesStore/38aa4922-e50c-43a4-8f96-4c7c978e8f6d","webscriptPerf":"9"}

Output from shell launched by cron :

{"result":[],"renderedTemplate":"","scriptPerf":"7","spacePath":"/Espace racine","printOutput":[],"spaceNodeRef":"workspace://SpacesStore/38aa4922-e50c-43a4-8f96-4c7c978e8f6d","webscriptPerf":"9"}

As you can see, there is empty printOutput... can't figure out why.

Do you have any idea for my problem ? Ask me if more details is needed !

0 REPLIES 0