How to pass in arguments from unix script to INFORMIX 4GL program
Posted in 2006
Poster wanted to drive an interactive Informix-4GL screen program (date prompts, then an optional screen array ended by F8) from a Korn shell script, without being allowed to change the 4GL code. Suggestions: store values in a table keyed by PID and look them up, or set environment variables read via fgl_getenv() — both rejected since the program can't be modified. Mario Canto's advice to pipe the exact keystrokes (including the F8 escape from tput, correct TERM, no stray CR/LF) worked for the first screen, but the program's tcflush(TCIFLUSH) call discarded queued input before the second screen. The only remaining suggestion was inserting a sleep/pause between the two input streams; no confirmed resolution is recorded.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
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.
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: > 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. > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list -- Mike Aubury
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] >> Informix-list@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?
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. On 5 May 2006 at 6:51, yy4 wrote: > 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. > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list >
mehdi2@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: >> >[quoted text clipped - 69 lines] >> Informix-list@iiug.org >> http://www.iiug.org/mailman/listinfo/informix-list 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.
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. On 5 May 2006 at 9:00, yy4 wrote: > mehdi2@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: > >> > >[quoted text clipped - 69 lines] > >> Informix-list@iiug.org > >> http://www.iiug.org/mailman/listinfo/informix-list > > 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. > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list >
mehdi2@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] >> Informix-list@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.
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 On 5 May 2006 at 10:00, yy4 wrote: > mehdi2@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] > >> Informix-list@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. > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list >
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 At 05:00 05/05/2006, yy4 wrote: >mehdi2@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: > >> > >[quoted text clipped - 69 lines] > >> Informix-list@iiug.org > >> http://www.iiug.org/mailman/listinfo/informix-list > >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. >_______________________________________________ >Informix-list mailing list >Informix-list@iiug.org >http://www.iiug.org/mailman/listinfo/informix-list
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] >>Informix-list@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
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 At 22:56 07/05/2006, yy4 via DBMonster.com wrote: >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] > >>Informix-list@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 >_______________________________________________ >Informix-list mailing list >Informix-list@iiug.org >http://www.iiug.org/mailman/listinfo/informix-list