Prashant wrote:
> On Monday, 21 October 2013 02:13:25 UTC+5:30, Keith wrote:
>
>>Prashant wrote:
>>
>>
>>>Hello All,
>>
>>>Can you please tell me that how I can call a "gtacl" routine on guardian from CGI program written in C on OSS enviornment.
>>
>>>Thanks in advance.
>>
>>>
>>
>>
>>
>>I imagine you are asking how to run a command from your CGI program that you can run using gtacl from an OSS prompt. If that is not what you were asking about, please try to explain further what you actually want to do.
>>
>>
>>
>>It seems that using the system() function would be the easiest way to do what you ask. Suppose the command you want to run from your CGI program was something that you could do from an OSS shell prompt by entering:
>>
>>
>>
>> gtacl -c ’stop \$abc’
>>
>>
>>
>>I believe you could do the same thing in your CGI program by calling the system() function like this:
>>
>>
>>
>> system("gtacl -c ’stop \$abc’");
>>
>>
>>
>>I have not used the system() function myself, so there might be some reason why this would not solve your problem. If I'm wrong, I hope someone else will answer and correct what I said here.
>>
>>
>>
>>If the gtacl command you want to run from your CGI program uses the -p option to run a Guardian program, you could do that by calling the Guardian procedures PROCESS_CREATE_ or PROCESS_LAUNCH_.. This would avoid starting a copy of the OSS shell, which would be slightly more efficient, but it would be quite a bit more complicated, since you have many more parameters to pass, and you must send the Guardian process you create a standard startup message sequence. It probably is not worth the extra complexity to use PROCESS_CREATE_ or PROCESS_LAUNCH_.
>
>
> Thanks Keith. I need to write a CGI program using C language. I have TACL routine written on guardian environment. So I have to call same TACL routine by passing few arguments in a CGI program using C language. I hope you got my point.
>
> Regarding, system() I will try with same and let you know if any issues. Thanks.
That is the scenario I thought you were asking about, but I was not completely sure of it. So you would want to use gtacl with -c, not -p.
Randall's suggestion to include -s may be helpful. The issue is that the Guardian startup sequence allows only 1024 characters for passing all of the environment variables and values. An OSS process often has a large number of environment variables -- sometimes enough to exceed that limit. When that happens, gtacl writes a warning message that says it was not able to send all of the environment variables to the Guardian process. The -s options tells gtacl not to send the environment variables, avoiding the possibility of getting that warning. If proper execution of the command sent via gtacl depends on an environment variable that did not get sent, that can cause a problem. If you need some environment variables to be available to the Guardian command, you could delete enough unneeded environment variables in your program before calling system() and not use the -s option.
I'm not completely sure what Randall means when he talks about quoting and shell variable expansion. If you understand his point, that is good, but if you do not understand it, it might be helpful to ask him to explain that point further. If the command you want to run via gtacl does not contain any characters that the shell uses in shell variable expansion or file name expansion, then the point he is making probably does not affect you.