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_001_01C43F0E.D6D47466 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thank you very much. I tried this and it worked very well. =20 I played around with the RETURN syntax, forgetting about the EXIT syntax. =20 =20 Thanks Fernando. =20 Regards Dirk =20 =20 -----Original Message----- From: Fernando Ortiz [mailto:fortiz@lacorona.com.mx]=20 Sent: Thursday, May 20, 2004 8:28 PM To: Dirk Moolman; informix-list@iiug.org Subject: Re: Passing a value from Unix into 4GL ? =20 Hi Dirk, =20 There's a workaround if the unix command only returns ONE integer value. =20 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. =20 [ortiz@adela bin]$ cat cuenta #/bin/bash a=3D`wc -l $1` b=3D`echo $a | cut -f 1 -d \ ` exit $b =20 And this small 4gl, prompts for a file name, runs the shell script and returns the 'exit code' from the script. =20 [ortiz@adela bin]$ cat cuenta.4gl MAIN =20 DEFINE w_arch char(30), w_comm char(80), w_line smallint =20 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 =20 END MAIN =20 =20 =20 The programs works BUT I need to divide the returning value by 256, maybe is a problem in my linux port. =20 [ortiz@adela bin]$ fglgo -V INFORMIX-4GL Version 7.30.UC7 Pcode Version 730 =20 =20 HTH ----- Original Message -----=20 From: Dirk Moolman <mailto To: informix-list@iiug.org=20 Sent: Thursday, May 20, 2004 10:56 AM Subject: Passing a value from Unix into 4GL ? =20 I am searching the net, but can't find an answer yet. =20 =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 ? =20 =20 Example: =20 =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. =20 Should be simple, but I don't know how ... =20 =20 =20 =20 =20 Dirk Moolman Database and Unix Administrator MXGROUP =20 =20 "People demand freedom of speech as a compensation for the freedom of thought which they seldom use."=20 -Kierkegaard=20 =20 =09 =09 =09 =09 ________________________________ << 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_001_01C43F0E.D6D47466 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)"> <style> <!-- /* Font Definitions */ @font-face {font-family:Courier; panose-1:2 7 4 9 2 2 5 2 4 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color text-decoration:underline;} p.MsoPlainText, li.MsoPlainText, div.MsoPlainText {margin:0in; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New";} span.EmailStyle18 {font-family:Arial; color:navy;} @page Section1 {size:8.5in 11.0in; margin:1.0in 77.95pt 1.0in 77.95pt;} div.Section1 {page:Section1;} --> </style> </head> <body bgcolor=3Dwhite lang=3DEN-US link=3Dblue vlink=3Dpurple> <div class=3DSection1> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Thank you very much. I tried = this and it worked very well.</span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>I played around with the RETURN = syntax, forgetting about the EXIT syntax.</span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Thanks Fernando.</span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Regards</span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Dirk</span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'> </span></font></p> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original = Message-----<br> <b><span style=3D'font-weight:bold'>From:</span></b> Fernando Ortiz [mailto:fortiz@lacorona.com.mx] <br> <b><span style=3D'font-weight:bold'>Sent:</span></b> Thursday, May 20, = 2004 8:28 PM<br> <b><span style=3D'font-weight:bold'>To:</span></b> Dirk Moolman; informix-list@iiug.org<br> <b><span style=3D'font-weight:bold'>Subject:</span></b> Re: Passing a = value from Unix into 4GL ?</span></font></p> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>Hi = Dirk,</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>There's a workaround if = the unix command only returns ONE integer value.</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>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.</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>[ortiz@adela bin]$ cat = cuenta<br> #/bin/bash<br> a=3D`wc -l $1`<br> b=3D`echo $a | cut -f 1 -d \ `<br> exit $b</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>And this small 4gl, = prompts for a file name, runs the shell script and returns the 'exit code' from the = script.</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'><br> [ortiz@adela bin]$ cat cuenta.4gl<br> MAIN</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>DEFINE w_arch = char(30),<br> w_comm char(80),<br> w_line smallint</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>PROMPT "File name ? = " FOR w_arch<br> LET w_comm =3D "cuenta ", w_arch<br> RUN w_comm RETURNING w_line<br> LET w_line =3D w_line / 256<br> DISPLAY "LINES =3D ", w_line</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>END = MAIN</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>The programs works BUT I = need to divide the returning value by 256, maybe is a problem in my linux = port.</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>[ortiz@adela bin]$ fglgo = -V<br> INFORMIX-4GL Version 7.30.UC7<br> Pcode Version 730</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DCourier><span style=3D'font-size:10.0pt;font-family:Courier'>HTH</span></font></p> </div> <blockquote style=3D'border:none;border-left:solid black = 1.5pt;padding:0in 0in 0in 4.0pt; margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'= > <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'>----- Original Message = ----- </span></font></p> </div> <div style=3D'font-color:black'> <p class=3DMsoNormal = style=3D'margin-left:.5in;background:#E4E4E4'><b><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial;font-weight:bold'>From:</span= ></font></b><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> <a href=3D"mailto Moolman</a> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><b><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial;font-weight:bold'>To:</span><= /font></b><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> <a href=3D"mailto:informix-list@iiug.org" = title=3D"informix-list@iiug.org">informix-list@iiug.org</a> </span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><b><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial;font-weight:bold'>Sent:</span= ></font></b><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> Thursday, May 20, 2004 10:56 AM</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><b><font size=3D2 = face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial;font-weight:bold'>Subject:</s= pan></font></b><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> Passing a value from Unix into 4GL ?</span></font></p> </div> <div> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </div> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>I am searching the net, but can't find an = answer yet. </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>How can I run a 4GL, that will run a Unix = command, and then keep</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>the result of the Unix command in a variable = in the 4GL ?</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><u><font size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>Example: = </span></font></u></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>Let's say I have a script that does a word = count (wc) on a file.</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>I want to run this script from a 4GL program, = and then use the result</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>of the word count in the = 4GL.</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>Should be simple, but I don't know how = ....</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>Dirk Moolman</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>Database and Unix = Administrator</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>MXGROUP</span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>"People demand freedom of speech as a compensation for the freedom of thought which they seldom use." = </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'>-Kierkegaard </span></font></p> <p class=3DMsoPlainText style=3D'margin-left:.5in'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt'> </span></font></p> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'><br> <br> </span></font></p> <!--Ella123--> <div class=3DMsoNormal align=3Dcenter = style=3D'margin-left:.5in;text-align:center'><font size=3D3 face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> <hr size=3D2 width=3D"100%" align=3Dcenter> </span></font></div> <table class=3DMsoNormalTable border=3D1 cellspacing=3D0 cellpadding=3D0 = width=3D626 bgcolor=3D"#FFFF99" = style=3D'width:469.6pt;margin-left:.5in;background:#FFFF99; border <tr> <td style=3D'border:inset #999999 1.0pt;padding:6.0pt 6.0pt 6.0pt = 6.0pt'> <p class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font = size=3D2 color=3D"#999999" face=3DTahoma><span = style=3D'font-size:10.0pt;font-family:Tahoma; color:#999999'><<</span></font><b><font size=3D2 = color=3D"#006600" face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial;color:#006600; font-weight:bold'> ella for Spam Control </span></font></b><font = size=3D2 color=3D"#999999" face=3DTahoma><span = style=3D'font-size:10.0pt;font-family:Tahoma; color:#999999'>>> </span></font><font size=3D2 color=3D"#333333" face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial;color:#333333'>has removed <b><span style=3D'font-weight:bold'>976</span></b> Spam = messages and set aside <b><span style=3D'font-weight:bold'>515</span></b> = Newsletters for me<br> You can use it too - and it's FREE!</span></font> <font = size=3D2 color=3D"#333333" face=3DTahoma><span = style=3D'font-size:10.0pt;font-family:Tahoma; color:#333333'><a = href=3D"http://www.ellaforspam.com">www.ellaforspam.com</a></span></font>= </p> </td> </tr> </table> <p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 = face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> </span></font></p> </blockquote> </div> </body> </html> =00 ------_=_NextPart_001_01C43F0E.D6D47466-- sending to informix-list |