Re: Passing a value from Unix into 4GL ?
Posted in 2004
This is a multi-part message in MIME format. ------=_NextPart_000_007F_01C43F1C.FAD4C9E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable It would be very useful if you send us an example of this solution.=20 Thanks in advance ----- Original Message -----=20 From: Preetinder Dhaliwal=20 To: Fernando Ortiz=20 Cc: Dirk Moolman ; informix-list@iiug.org=20 Sent: Friday, May 21, 2004 12:47 AM Subject: Re: Passing a value from Unix into 4GL ? Hi, If u r looking at returning strings etc to 4gl, use c program = instead of 4gl. Use popen to open the shell command and then u can read = standard output ( just like u read from a file ). Once u have this = string ( can be anything from line count to echo message ), parse it = according to ur needs and pass back to 4gl ( thru retquote or similar ) rgds Preetinder Fernando Ortiz wrote: Hi Dirk, There's a workaround if the unix command only returns ONE integer = value. As you can see I'm not a shell programmer, but the following script = do a line count in the file given as first parameter and then returns = the line count as the exit code. [ortiz@adela bin]$ cat cuenta #/bin/bash a=3D`wc -l $1` b=3D`echo $a | cut -f 1 -d \\ ` exit $b And this small 4gl, prompts for a file name, runs the shell script = and returns the 'exit code' from the script. [ortiz@adela bin]$ cat cuenta.4gl MAIN DEFINE w_arch char(30), w_comm char(80), w_line smallint PROMPT "File name ? " FOR w_arch LET w_comm =3D "cuenta ", w_arch RUN w_comm RETURNING w_line LET w_line =3D w_line / 256 DISPLAY "LINES =3D ", w_line END MAIN The programs works BUT I need to divide the returning value by 256, = maybe is a problem in my linux port. [ortiz@adela bin]$ fglgo -V INFORMIX-4GL Version 7.30.UC7 Pcode Version 730 HTH ----- Original Message -----=20 From: Dirk Moolman=20 To: informix-list@iiug.org=20 Sent: Thursday, May 20, 2004 10:56 AM Subject: Passing a value from Unix into 4GL ? I am searching the net, but can't find an answer yet. =20 How can I run a 4GL, that will run a Unix command, and then keep the result of the Unix command in a variable in the 4GL ? Example: =20 Let's say I have a script that does a word count (wc) on a file. I want to run this script from a 4GL program, and then use the = result of the word count in the 4GL. Should be simple, but I don't know how ... Dirk Moolman Database and Unix Administrator MXGROUP "People demand freedom of speech as a compensation for the freedom = of thought which they seldom use."=20 -Kierkegaard=20 -------------------------------------------------------------------------= - << ella for Spam Control >> has removed 976 Spam messages = and set aside 515 Newsletters for me You can use it too - and it's FREE! www.ellaforspam.com=20 ------=_NextPart_000_007F_01C43F1C.FAD4C9E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE></TITLE> <META http-equiv=3DContent-Type = content=3Dtext/html;charset=3DISO-8859-1> <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD> <BODY text=3D#000000 bgColor=3D#ffffff> <DIV><FONT face=3DTahoma size=3D2>It would be very useful if you send us = an example=20 of this</FONT></DIV> <DIV><FONT face=3DTahoma size=3D2>solution. </FONT></DIV> <DIV><FONT face=3DTahoma size=3D2></FONT> </DIV> <DIV><FONT face=3DTahoma size=3D2>Thanks in advance</FONT></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Dpreetinder.dhaliwal@dhl.com=20 href=3D"mailto:preetinder.dhaliwal@dhl.com">Preetinder Dhaliwal</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3Dfortiz@lacorona.com.mx=20 href=3D"mailto:fortiz@lacorona.com.mx">Fernando Ortiz</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Cc:</B> <A = title=3DDirkM@mxgroup.co.za=20 href=3D"mailto:DirkM@mxgroup.co.za">Dirk Moolman</A> ; <A=20 title=3Dinformix-list@iiug.org=20 href=3D"mailto:informix-list@iiug.org">informix-list@iiug.org</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, May 21, 2004 = 12:47 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Passing a value = from Unix=20 into 4GL ?</DIV> <DIV><BR></DIV>Hi,<BR><BR> If u r looking at = returning=20 strings etc to 4gl, use c program instead of 4gl. Use popen to open = the shell=20 command and then u can read standard output ( just like u read from a = file ).=20 Once u have this string ( can be anything from line count to echo = message ),=20 parse it according to ur needs and pass back to 4gl ( thru retquote or = similar=20 )<BR><BR>rgds<BR>Preetinder<BR><BR>Fernando Ortiz wrote:<BR> <BLOCKQUOTE cite=3Dmid016d01c43e98$2b053850$610206c0@fjcorona.com.mx=20 type=3D"cite"> <META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR> <STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 77.95pt = 1.0in 77.95pt; } P.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman" } LI.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman" } DIV.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman" } A:link { COLOR: blue; TEXT-DECORATION: underline } SPAN.MsoHyperlink { COLOR: blue; TEXT-DECORATION: underline } A:visited { COLOR: purple; TEXT-DECORATION: underline } SPAN.MsoHyperlinkFollowed { COLOR: purple; TEXT-DECORATION: underline } P.MsoPlainText { FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New" } LI.MsoPlainText { FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New" } DIV.MsoPlainText { FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New" } DIV.Section1 { page: Section1 } </STYLE> <DIV><FONT face=3DCourier size=3D2>Hi Dirk,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>There's a workaround if the unix = command only=20 returns ONE integer value.</FONT></DIV> <DIV> </DIV> <DIV><