tSystem cUrl cmd doesnt work from a builded job but it works in prompt

Ten Stars

tSystem cUrl cmd doesnt work from a builded job but it works in prompt

Dear experts,

 

Im clueless on this ...  I have a job which uses tSytem to run cUrl command. Until (today) it worked... 

curl -k -L -v -c /data/cookies/cookie.txt -X POST -d "login=login&username=myusername&password=pwd" https://*************.nl/login

So I've tested and tested and tested.... 

- delete cookie.txt before starting.

- run in Windows command prompt : success,

- run in Unix (RedHat) shell prompt : succes,

- Windows Talend Job, tSystem : success,

- Build Talend Job, run bat script, success

- Copy paste Talend Job -> Unix, run sh script, curl command works ......  but .... doesnt login and shows/redirects me to the login page... 

I also dumped the string which is used in tSystem to stdout/console and copy paste in shell ... again success.

- Everything runs by the same user... 

- User-agent is always the same, headers are the same. 

- Environment variables are the same...

 

I really could use some expert advise on this. Clearly Im missing something and this is freaking me out!!!

Tags (2)

Accepted Solutions
Ten Stars

Re: tSystem cUrl cmd doesnt work from a builded job but it works in prompt

Thanks, for your suggestions, I was thinking about that it might be something like an environment shell config... but still clueless on why it worked.. probably the cookie or some (server) cache wasn't expired, or it used the 'old' cookie ... untill today.

Yet I found the solution on how to run it properly, in tSystem just call it like an array command:

new String[]{"bash","-c","curl -k -L -v -c /data/cookies/cookie.txt  https://**************.nl/login -d 'login=login&username=********&password=**********' "}

Success


All Replies
Sixteen Stars

Re: tSystem cUrl cmd doesnt work from a builded job but it works in prompt

This does seem odd. Can you try something out which might give us some clues? I suspect that the tSystem is running in a subshell in Unix and that it might not have all of the same environment config as the shell you are manually running with. Could you create a script which fires the curl command you require and create a small job to just run that script using the tSystem. Obviously test the script without the job first. If you get a different result it suggests that the environment that the tSystem is running the commands under is not the same. If that is the case, try using the tSystem to manually load the shell you want (with environment settings) and then fire the script. If that works, you should be able to do the same but call curl as you are now.

 

Unfortunately I have never had this issue, so the above are merely the steps I would take to try to resolve it.

Ten Stars

Re: tSystem cUrl cmd doesnt work from a builded job but it works in prompt

Thanks, for your suggestions, I was thinking about that it might be something like an environment shell config... but still clueless on why it worked.. probably the cookie or some (server) cache wasn't expired, or it used the 'old' cookie ... untill today.

Yet I found the solution on how to run it properly, in tSystem just call it like an array command:

new String[]{"bash","-c","curl -k -L -v -c /data/cookies/cookie.txt  https://**************.nl/login -d 'login=login&username=********&password=**********' "}

Success