vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| This is a multi-part message in MIME format. ------=_NextPart_000_016A_01C43E6E.42044FC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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_016A_01C43E6E.42044FC0 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> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <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> </HEAD> <BODY lang=3DEN-US vLink=3Dpurple link=3Dblue bgColor=3D#ffffff> <DIV><FONT face=3DCourier size=3D2>Hi Dirk,</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>There's a workaround if the unix = command only=20 returns ONE integer value.</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>As you can see I'm not a shell = programmer, but=20 the following script do a line count in the file given as first = parameter and=20 then returns the line count as the exit code.</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>[ortiz@adela bin]$ cat=20 cuenta<BR>#/bin/bash<BR>a=3D`wc -l $1`<BR>b=3D`echo $a | cut -f 1 -d = \ =20 `<BR>exit $b</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>And this small 4gl, prompts for a = file name, runs=20 the shell script and returns the 'exit code' from the = script.</FONT></DIV> <DIV><FONT face=3DCourier size=3D2> </DIV> <DIV><BR>[ortiz@adela bin]$ cat cuenta.4gl<BR>MAIN</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>DEFINE w_arch=20 char(30),<BR> w_comm=20 char(80),<BR> w_line = smallint</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>PROMPT "File name ? " FOR = w_arch<BR>LET w_comm =3D=20 "cuenta ", w_arch<BR>RUN w_comm RETURNING w_line<BR>LET w_line =3D = w_line /=20 256<BR>DISPLAY "LINES =3D ", w_line</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>END MAIN</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>The programs works BUT I need to = divide the=20 returning value by 256, maybe is a problem in my linux = port.</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV><FONT face=3DCourier size=3D2>[ortiz@adela bin]$ fglgo = -V<BR>INFORMIX-4GL=20 Version 7.30.UC7<BR>Pcode Version 730</FONT></DIV> <DIV><FONT face=3DCourier size=3D2></FONT> </DIV> <DIV> </DIV> <DIV><FONT face=3DCourier size=3D2>HTH</FONT></DIV> <BLOCKQUOTE=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=3DDirkM@mxgroup.co.za = href=3D"mailto Moolman</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = 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> Thursday, May 20, 2004 = 10:56=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Passing a value from = Unix into=20 4GL ?</DIV> <DIV><FONT face=3DCourier size=3D2></FONT><FONT face=3DCourier=20 size=3D2></FONT><BR></DIV> <DIV class=3DSection1> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">I am searching the net, but can't find an = answer=20 yet. </SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3DCourier size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">How can I run a 4GL, that will run a Unix = command, and=20 then keep</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">the result of the Unix command in a variable = in the=20 4GL ?</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><U><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">Example: </SPAN></FONT></U></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">Let's say I have a script that does a word = count (wc)=20 on a file.</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">I want to run this script from a 4GL = program, and then=20 use the result</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">of the word count in the = 4GL.</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">Should be simple, but I don't know how=20 ...</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">Dirk Moolman</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">Database and Unix = Administrator</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">MXGROUP</SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt"></SPAN></FONT> </P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">"People demand freedom of speech as a = compensation for=20 the freedom of thought which they seldom use." </SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: 10pt">-Kierkegaard </SPAN></FONT></P> <P class=3DMsoPlainText><FONT face=3D"Courier New" size=3D2><SPAN=20 style=3D"FONT-SIZE: = 10pt"></SPAN></FONT> </P></DIV><BR><!--Ella123--> <HR> <TABLE borderColor=3D#999999 cellSpacing=3D0 cellPadding=3D8 = bgColor=3D#ffff99=20 border=3D1> <TBODY> <TR> <TD align=3Dmiddle><FONT face=3DTahoma,Arial,San-Serif = color=3D#999999=20 size=3D2><<</FONT><FONT face=3DTrebuchet,Arial,San-Serif = color=3D#006600=20 size=3D2><B> ella for Spam Control </FONT></B><FONT=20 face=3DTahoma,Arial,San-Serif color=3D#999999 size=3D2>>> = </FONT><FONT=20 face=3DTrebuchet,Arial,San-Serif color=3D#333333 size=3D2>has = removed=20 <B>976</B> Spam messages and set aside <B>515</B> Newsletters = for=20 me<BR>You can use it too - and it's = FREE!</FONT> <FONT=20 face=3DTahoma,Arial,San-Serif color=3D#333333 size=3D2><A=20 = href=3D"http://www.ellaforspam.com">www.ellaforspam.com</A></FONT></TD></= TR></TBODY></TABLE></BLOCKQUOTE></BODY></HTML> ------=_NextPart_000_016A_01C43E6E.42044FC0-- sending to informix-list |