Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Powerbuilder call to a url to execute a perl script

435 views
Skip to first unread message

jckrell

unread,
Jul 14, 2014, 6:17:20 PM7/14/14
to
Hello, I need to call a url from Powerbuilder which will execute a perl cgi script. I need to pass one parameter to the script. I do not need to return anything from the script but do want to check to make sure the call to the url was successful.
I'm not a Powerbuilder programmer but I do need to make several changes to an existing system. I've looked for ways to do this but i've not found anything that helps much. I know there is the geturl and posturl and HyperLinkToURl but not sure which one to use. All I want to do is call this url which will execute the cgi script. Can I just use the HyperlinkToUrl function since i'm not retrieving data? If so how can I check to make sure the call to the url was successful?


string ls_url ls_parameter1
inet ii_net_base

ls_url = "http://www.example.com/cgi-bin/test.pl&"
ls_url += "ls_parameter1"
GetContextService("Internet", ii_net_base)

ii_net_base.HyperlinkToUrl(ls_url)

steven.va...@gmail.com

unread,
Jul 15, 2014, 4:34:39 AM7/15/14
to
Op dinsdag 15 juli 2014 00:17:20 UTC+2 schreef jckrell:
The easiest thing would be for your cgi script to return some html code. So if it's succesful, have it return a different value then when it has failed. That way, in the powerbuilder code, you can call the url and use the return html to determine if your perl script was a success.

As for calling a perl script; I'm going to assume it'll run on a server somewhere so you can trigger it by calling a URL. If so, then the following will apply:

Create a new Standard Class. When prompted, choose the internetresult class. In the newly created class you'll need to program the internetdata (blob data) function. This class will be used when calling a URL and the internetdata function is a standard function that handles the result your receive from the URL. Typically the blob will be ANSI encoded, so you'll want to convert it. Just put the result into an instance variable would be my suggestion:

is_return = String(data, EncodingANSI!)

From the place where you want to call your perl script, you then need to initialize your new class as well as the class INET:

n_internetresult_yourclass lv_ir_yourclass
inet lv_inet

lv_ir_yourclass = create n_internetresult_yourclass
lv_inet = create inet

The inet class is then used to call your URL, your internetresult class will handle the HTML you get back:

lv_inet.getUrl('address-of-your-perl-script', lv_ir_yourclass)

And you can retrieve the result (which should contain the variabele html, telling you if the perl script was successful) from the instance variabele:

lb_result = lv_ir_yourclass.is_return = 1

And with that, you can now do whatever you wish to do in the case of a sucessful action or a not so successful one:

if lb_result then
MessageBox('Huzzah!', 'It worked!')
else
MessageBox('Boo!', 'Drat; didn't work...')
end if

steven.va...@gmail.com

unread,
Jul 15, 2014, 7:38:07 AM7/15/14
to
Op dinsdag 15 juli 2014 10:34:39 UTC+2 schreef steven.va...@gmail.com:
Forgot to mention, but: this reply is based on Powerbuilder classic, not .Net.

jckrell

unread,
Jul 15, 2014, 3:15:52 PM7/15/14
to
Thanks for the great help. Yes, the perl script will reside on a server.
I'll just return a status from the perl script and code it like your example using the geturl with the internetresult class.
Thanks.
0 new messages