Sat Aug 18, 2018 11:51 pm
Login Register Lost Password? Contact Us


Passing a Value from Unix to ECL script

Questions around writing code and queries

Fri Feb 23, 2018 8:35 am Change Time Zone

HI ALL,
I have one sample ECL script as below
[hpcc@hcdevlz Recordtest]$ head renderRecordString.ecl
IMPORT STD;

STRING IP :='http://10.224.84.2';
STRING port_ := '8010';
STRING FileName := '~thorde::future::Testpolicy';
STRING Cluster := '';
STRING include_fpos := 'N';

// Build the soap URL
STRING URl := IP+':'+(STRING)port_+'/WsDfu/';
---------------------------------------------------------
In above ECL script i want this ECL to accept parameter FileName from Unix which can be passed as while running shell Script .

Example
./Unixwrapper.sh thorde::future::Testpolicy


Is it possible to pass parameter used by ECL to be sent by UNIX.Kindly help me with the same.


Regards
Harsh Desai
harshdesai
 
Posts: 7
Joined: Fri Feb 23, 2018 8:30 am

Fri Feb 23, 2018 12:56 pm Change Time Zone

I am sure there are a couple of ways to tackle this but a simple approach might be the following.

1. Your code needs to be compiled and published as a query on either thor or hthor with input query parameters.

IMPORT STD;

STRING IP :='http://10.224.84.2';
STRING port_ := '8010';
STRING FileName := '~thorde::future::Testpolicy' : STORED('InFile');
STRING Cluster := '' : STORED('InCluster');
STRING include_fpos := 'N';

// Build the soap URL
STRING URl := IP+':'+(STRING)port_+'/WsDfu/';
// Do soap call and other stuff here...

2. Test that out by manually loading the form on WSECL (eclwatch ip but port 8002) and make sure it works like you want.

3. Once your query is working, call it from a UNIX script using curl and the URL of the query that you have published with the parameter in the URL.
http://<ipaddress>:8002/WsEcl/xslt/query/hthor/myeclquery?infile=~thorde::future::Testpolicy&InCluster=mythor

Take it one step at a time and ask questions if you need more info on publishing queries etc..

HTH

Jo
jprichard
 
Posts: 5
Joined: Fri Jul 27, 2012 4:09 pm

Fri Feb 23, 2018 1:02 pm Change Time Zone

Harsh,

Just to expand a bit on Jo's reply - the process of pre-compiling and publishing queries is covered in both of our online Roxie courses, available here: https://hpccsystems.com/training#Classes

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1370
Joined: Wed Oct 26, 2011 7:40 pm

Fri Mar 02, 2018 6:35 pm Change Time Zone

Thanks Richard
harshdesai
 
Posts: 7
Joined: Fri Feb 23, 2018 8:30 am

Fri May 25, 2018 7:48 am Change Time Zone

Hi Harsh,

As Jo said there are a number of ways to accomplish this.

I've just constructed ECL in a ksh script, then executed it using Perl CPAN libraries (LWP::UserAgent). Once you have a nice Perl script written, running ECL WU from Unix is trivial.

You don't have to publish any queries this way.
Yours
Allan
Allan
 
Posts: 306
Joined: Sat Oct 01, 2011 7:26 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron