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

How to pass in arguments from unix script to INFORMIX 4GL program

471 views
Skip to first unread message

yy4

unread,
May 5, 2006, 2:51:49 AM5/5/06
to
Let me explain the background of my problem before I post any question:

I have a few programs as below:

Program id: onkey.4gh
--------------------------------
....
....
on key (F8) let g_onkey = 8
....


Program id: hotkeys.h
------------------------------
....
#define F8_KEY 8
.....

Main Program id: Prog.4gl
-------------------------------------
#include hotkeys.h

Function input_scr()
display form

input array arr1 without defaults from sa_arr1
......
.....
#include "onkey.4gh"
case
when (g_hotkey = F8_KEY)
call generate_rpt()
end case
......
End Function


Problem:
------------
I wish to automate this INFORMIX 4GL program by passing in the input values
as an arguments from a calling unix scripts.

The sequence INFORMIX 4GL screen input will be as below:
1. enter screen array with 2 fields - account No, account name
e.g of the input screen will be

Account No Account Name
[A ] [A/C Name A]
[B] [A/C Name B]
[C] [A/C Name C]

2. press F8 ctrl-key to generate the report

My unix script (korn shell) will be something as below:
ksh -c "echo <array input value><F8 ctrl-key> |/proj/prog.exe " << ^M
!

Note: /proj/prog.exe is my INFORMIX-4GL executable.

Question:
1. How to pass in a set of <array input value> from the scripts to an
informix 4GL program?
2. The input array are optional, user can enter value in the array or just
leave the entry empty and press F8 to proceed with the process. In this case,
how to pass in an empty array values from a unix script (korn shell) to an
Informix-4GL program?

I am facing this problem and need resolution urgently, please.

I will be glad if anyone can help me on this issue.
Thanks in advacne.

Mike Aubury

unread,
May 5, 2006, 2:56:21 AM5/5/06
to inform...@iiug.org, yy4
If it were me - I'd load a table in the database with the values, probably
using the process ID of the script as a key.
Then pass that process ID into the 4gl program where it looks those values
up...
> _______________________________________________
> Informix-list mailing list
> Inform...@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list

--
Mike Aubury

yy4

unread,
May 5, 2006, 3:04:09 AM5/5/06
to
Mike Aubury wrote:
>If it were me - I'd load a table in the database with the values, probably
>using the process ID of the script as a key.
>Then pass that process ID into the 4gl program where it looks those values
>up...
>> Let me explain the background of my problem before I post any question:
>>
>[quoted text clipped - 69 lines]
>> Inform...@iiug.org
>> http://www.iiug.org/mailman/listinfo/informix-list
>


I am not too sure what you meant, could you please explain further how to do
it?

meh...@querix.com

unread,
May 5, 2006, 4:48:32 AM5/5/06
to yy4, inform...@iiug.org
Hi;

You can use your script file to set some envirenment variables, and
then use fgl_getenv() to bring the information into the 4gl program.

yy4

unread,
May 5, 2006, 5:00:09 AM5/5/06
to
meh...@querix.com wrote:
>Hi;
>
>You can use your script file to set some envirenment variables, and
>then use fgl_getenv() to bring the information into the 4gl program.
>
>> Let me explain the background of my problem before I post any question:
>>

Thanks for you reply.

But then I can't modify the 4gl program in this case which my boss won't
allow me to do so. All I have to do is only pass in the values from script
itself to the 4GL program in order to automate the process.

Any idea to resolve this?
Please help it is urgent.

meh...@querix.com

unread,
May 5, 2006, 5:50:28 AM5/5/06
to yy4, inform...@iiug.org
Are you trying to create a script for testing your 4GL program? if so,
you will have to run the program manually and capture all key strokes,
then run this file as through some one was physically running the
program. you can edit this file to create a varying situation, and you can
create a loop to carry on the process. Further you can capture the
results of what is happening when in your 4gl as a result of different
key presses by capturing the information.

To do all this you have various options in re directing the input and out
put of programs in Unix.

yy4

unread,
May 5, 2006, 6:00:15 AM5/5/06
to
meh...@querix.com wrote:
>Are you trying to create a script for testing your 4GL program? if so,
>you will have to run the program manually and capture all key strokes,
>then run this file as through some one was physically running the
>program. you can edit this file to create a varying situation, and you can
>create a loop to carry on the process. Further you can capture the
>results of what is happening when in your 4gl as a result of different
>key presses by capturing the information.
>
>To do all this you have various options in re directing the input and out
>put of programs in Unix.
>
>> >Hi;
>> >
>[quoted text clipped - 19 lines]
>> Inform...@iiug.org
>> http://www.iiug.org/mailman/listinfo/informix-list

Thanks again for your prompt reply.
The unix script that I am writting is NOT to test my 4GL program. It is help
to automate our process during batch run.

Sorry, I am very expert in unix shell programming, do you might providing
some examples how it works as you explain earlier.
e.g capturing key stores, re-directing the input and output and so on...

I know I am asking too much, but I have no clue as this moment as the
schedule is tight. I am still working on it right now and search for the
resolution.

Once again thanks in advance for your help.

meh...@querix.com

unread,
May 5, 2006, 6:44:58 AM5/5/06
to yy4, inform...@iiug.org
Here is a link to an OS software which has more capibilities than what I
was explaining before. You may be able to reconfigure them for your
purpose.

http://staf.sourceforge.net/index.php

Mario R. Canto

unread,
May 5, 2006, 2:40:52 PM5/5/06
to yy4, inform...@iiug.org
If you redirect input to the 4gl program (i.e. pipe from the script) the
4gl program takes data as if it were typed on a keyboard.
BUT you have to write to the output of your script EXACTLY what the
programs expects. If you have some AUTONEXT fields and you send the total
of bytes, that that field accept, then you must not send CR or LF.
The best approach is to try in the keyboard taking note of all the key
pressed, including F8 (and it escape sequence)
Don´t forget to define the TERM environment variable to that corresponding
to the kind of terminal you usually use.
It is convenient also, to redirect output to /dev/null.

HTH

Mario R. Canto

yy4 via DBMonster.com

unread,
May 7, 2006, 10:56:48 PM5/7/06
to
Mario R. Canto wrote:
>If you redirect input to the 4gl program (i.e. pipe from the script) the
>4gl program takes data as if it were typed on a keyboard.
>BUT you have to write to the output of your script EXACTLY what the
>programs expects. If you have some AUTONEXT fields and you send the total
>of bytes, that that field accept, then you must not send CR or LF.
>The best approach is to try in the keyboard taking note of all the key
>pressed, including F8 (and it escape sequence)
>Don´t forget to define the TERM environment variable to that corresponding
>to the kind of terminal you usually use.
>It is convenient also, to redirect output to /dev/null.
>
>HTH
>
>Mario R. Canto
>
>> >Hi;
>> >
>[quoted text clipped - 19 lines]
>>Inform...@iiug.org
>>http://www.iiug.org/mailman/listinfo/informix-list


Thank you very much for your valuable advise from Mario R. Canto and mehdi2.
I have now able to capture all the keystroke. But still have 1 problem as
describe below:

My 4GL program have 2 screens to prompt user for input:

1st screen:
prompt for date1 and date2

2nd screen:
prompt for input array for account no and name and press F8 to process. For
the 2nd screen, the input is optional, user can just leave the entry blank
and press F8 to proceed.

The problem occured and it stopped at the 2nd screen whereby the 4GL program
was calling the tcflush function before the input array.

I am not so sure about the tcflush functionality but found some knowledge
thru internet:

***** tcflush description start*******
tcflush - flush non-transmitted output data, non-read input data or both.

DESCRIPTION
Upon successful completion, tcflush() discards data written to the object
referred to by fildes (an open file descriptor associated with a terminal)
but not transmitted, or data received but not read, depending on the value of
queue_selector:

If queue_selector is TCIFLUSH it flushes data received but not read.
......
Attempts to use tcflush() from a process which is a member of a background
process group on a fildes associated with its controlling terminal, will
cause the process group to be sent a SIGTTOU signal. If the calling process
is blocking or ignoring SIGTTOU signals, the process is allowed to perform
the operation, and no signal is sent.

***** tcflush description end*******

Note: there are a few queue_selector, but we are using TCIFLUSH in my 4GL
program.

I have tried commented the calling function of TCIFLUSH in my 4GL program,
and my script is working totally fine. However, my boss has given the
instruction not to modify any 4GL program. So, anyone has any clue to resolve
this?

My unix script is as below:
ksh -c "echo 31/08/2005 31/08/2005^M^M$(tput kf8)|/proj/prog.exe" <<!

^M

!


Is there anywhere to include a pause in echo before the 2nd parameters
passing in to my 4gl program in unix script?

e.g

ksh -c "echo 31/08/2005 31/08/2005^M^M <anywhere to include a Pause in
between here > $(tput kf8)|/proj/prog.exe" <<!

^M

!

Thank you.

--
Message posted via http://www.dbmonster.com

Mike Aubury

unread,
May 8, 2006, 5:10:29 AM5/8/06
to inform...@iiug.org, yy4
I don't understand why your trying to make this so complicated..


script :

# sometab : create table sometab (pid integer,col1 char(10),col2 char(20));
echo "insert into sometable values($$,'xx1','yy1')" | dbaccess somedb -
echo "insert into sometable values($$,'xx2','yy2')" | dbaccess somedb -
echo "insert into sometable values($$,'xx3','yy3')" | dbaccess somedb -

# rds :
fglgo someprog $$
# c4gl/aubit
someprog $$


someprog.4gl

main
define lv_arr array[200] of record
x char(10),
y char(20)
end record
define lv_cnt integer
define lv_pid integer
let lv_pid=arg_val(1)
let lv_cnt=1

declare c1 cursor for
select col1,col2 from sometab where pid=lv_pid

foreach c1 into lv_arr[lv_cnt].*
let lv_cnt=lv_cnt+1
end foreach
let lv_cnt=lv_cnt-1

call set_count(lv_cnt)

input array ...


On Friday 05 May 2006 07:56, Mike Aubury wrote:
> If it were me - I'd load a table in the database with the values, probably
> using the process ID of the script as a key.
> Then pass that process ID into the 4gl program where it looks those values
> up...
>

> On Friday 05 May 2006 07:51, yy4 wrote:

> > _______________________________________________
> > Informix-list mailing list
> > Inform...@iiug.org
> > http://www.iiug.org/mailman/listinfo/informix-list

--
Mike Aubury

Mario Canto

unread,
May 8, 2006, 10:24:37 AM5/8/06
to Inform...@iiug.org
If you redirect input to the 4gl program (i.e. pipe from the script) the
4gl program takes data as if it were typed on a keyboard.
BUT you have to write to the output of your script EXACTLY what the
programs expects. If you have some AUTONEXT fields and you send the total
of bytes, that that field accept, then you must not send CR or LF.
The best approach is to try in the keyboard taking note of all the key
pressed, including F8 (and it escape sequence)
Don´t forget to define the TERM environment variable to that corresponding
to the kind of terminal you usually use.
It is convenient also, to redirect output to /dev/null.

HTH

Mario R. Canto

>_______________________________________________
>Informix-list mailing list
>Inform...@iiug.org
>http://www.iiug.org/mailman/listinfo/informix-list

--
Ing. Mario R. Canto
mrc...@gmail.com

Mario R. Canto

unread,
May 8, 2006, 10:34:37 AM5/8/06
to yy4 via DBMonster.com, inform...@iiug.org
What about a "sleep" between the first stream of data (after the 1st F8),
and the 2nd to the second screen?
HTH, again

Mario R. Canto

yy4 via DBMonster.com

unread,
May 9, 2006, 10:36:18 PM5/9/06
to
Mario R. Canto wrote:
>What about a "sleep" between the first stream of data (after the 1st F8),
>and the 2nd to the second screen?
>HTH, again
>
>Mario R. Canto
>
>> >If you redirect input to the 4gl program (i.e. pipe from the script) the
>> >4gl program takes data as if it were typed on a keyboard.
>[quoted text clipped - 89 lines]
>>Inform...@iiug.org
>>http://www.iiug.org/mailman/listinfo/informix-list

Hi Mario,

I have tried to put a sleep, but it is not working too. Any other clue to
resolve this ?

--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums.aspx/informix/200605/1

naj....@seznam.cz

unread,
May 11, 2006, 6:48:50 AM5/11/06
to

yy4 wrote:
....

> But then I can't modify the 4gl program in this case which my boss won't
> allow me to do so. All I have to do is only pass in the values from script
> itself to the 4GL program in order to automate the process.
>
> Any idea to resolve this?
> Please help it is urgent.
hmm, maybe http://wiki.tcl.tk/expect
--honza

0 new messages