This is a discussion on Re: Passing a value from Unix into 4GL ? within the Informix forums, part of the Database Server Software category; --> This is a multi-part message in MIME format. --------------030503080109060305010003 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit that will be a ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| This is a multi-part message in MIME format. --------------030503080109060305010003 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit that will be a prob with exit value more that 255 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=`wc -l $1` > b=`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 = "cuenta ", w_arch > RUN w_comm RETURNING w_line > LET w_line = w_line / 256 > DISPLAY "LINES = ", 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 ----- > From: Dirk Moolman <mailto > To: informix-list@iiug.org <mailto:informix-list@iiug.org> > 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. > > > > 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: > > > > 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." > > -Kierkegaard > > > > > ------------------------------------------------------------------------ > << 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 > <http://www.ellaforspam.com> > --------------030503080109060305010003 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title></title> </head> <body text="#000000" bgcolor="#ffffff"> that will be a prob with exit value more that 255<br> <br> Rgds<br> Preetinder<br> <br> Fernando Ortiz wrote:<br> <blockquote type="cite" cite="mid016d01c43e98$2b053850$610206c0@fjcorona.c om.mx"> <meta http-equiv="Content-Type" content="text/html; "> <meta content="MSHTML 6.00.2800.1400" name="GENERATOR"> <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="Courier" size="2">Hi Dirk,</font></div> <div> </div> <div><font face="Courier" size="2">There's a workaround if the unix command only returns ONE integer value.</font></div> <div> </div> <div><font face="Courier" size="2">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.</font></div> <div> </div> <div><font face="Courier" size="2">[ortiz@adela bin]$ cat cuenta<br> #/bin/bash<br> a=`wc -l $1`<br> b=`echo $a | cut -f 1 -d \ `<br> exit $b</font></div> <div> </div> <div><font face="Courier" size="2">And this small 4gl, prompts for a file name, runs the shell script and returns the 'exit code' from the script.</font></div> <div><font face="Courier" size="2"> </font></div> <div><font face="Courier" size="2"><br> [ortiz@adela bin]$ cat cuenta.4gl<br> MAIN</font></div> <div> </div> <div><font face="Courier" size="2">DEFINE w_arch char(30),<br> w_comm char(80),<br> w_line smallint</font></div> <div> </div> <div><font face="Courier" size="2">PROMPT "File name ? " FOR w_arch<br> LET w_comm = "cuenta ", w_arch<br> RUN w_comm RETURNING w_line<br> LET w_line = w_line / 256<br> DISPLAY "LINES = ", w_line</font></div> <div> </div> <div><font face="Courier" size="2">END MAIN</font></div> <div> </div> <div> </div> <div> </div> <div><font face="Courier" size="2">The programs works BUT I need to divide the returning value by 256, maybe is a problem in my linux port.</font></div> <div> </div> <div><font face="Courier" size="2">[ortiz@adela bin]$ fglgo -V<br> INFORMIX-4GL Version 7.30.UC7<br> Pcode Version 730</font></div> <div> </div> <div> </div> <div><font face="Courier" size="2">HTH</font></div> <blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;">----- Original Message ----- </div> <div style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-inline-policy: initial; -moz-background-origin: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>From:</b> <a title="DirkM@mxgroup.co.za" href="mailto Moolman</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>To:</b> <a title="informix-list@iiug.org" href="mailto:informix-list@iiug.org">informix-list@iiug.org</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>Sent:</b> Thursday, May 20, 2004 10:56 AM</div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-stretch: normal; font-size-adjust: none;"><b>Subject:</b> Passing a value from Unix into 4GL ?</div> <div><br> </div> <div class="Section1"> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">I am searching the net, but can't find an answer yet. </span></font></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">How can I run a 4GL, that will run a Unix command, and then keep</span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">the result of the Unix command in a variable in the 4GL ?</span></font></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><u><font face="Courier New" size="2"><span style="font-size: 10pt;">Example: </span></font></u></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">Let's say I have a script that does a word count (wc) on a file.</span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">I want to run this script from a 4GL program, and then use the result</span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">of the word count in the 4GL.</span></font></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">Should be simple, but I don't know how ...</span></font></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">Dirk Moolman</span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">Database and Unix Administrator</span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">MXGROUP</span></font></p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"> </p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">"People demand freedom of speech as a compensation for the freedom of thought which they seldom use." </span></font></p> <p class="MsoPlainText"><font face="Courier New" size="2"><span style="font-size: 10pt;">-Kierkegaard </span></font></p> <p class="MsoPlainText"> </p> </div> <br> <!--Ella123--> <hr> <table bordercolor="#999999" cellspacing="0" cellpadding="8" bgcolor="#ffff99" border="1"> <tbody> <tr> <td align="middle"><font face="Tahoma,Arial,San-Serif" color="#999999" size="2"><<</font><font face="Trebuchet,Arial,San-Serif" color="#006600" size="2"><b> ella for Spam Control </b></font><font face="Tahoma,Arial,San-Serif" color="#999999" size="2">>> </font><font face="Trebuchet,Arial,San-Serif" color="#333333" size="2">has removed <b>976</b> Spam messages and set aside <b>515</b> Newsletters for me<br> You can use it too - and it's FREE!</font> <font face="Tahoma,Arial,San-Serif" color="#333333" size="2"><a href="http://www.ellaforspam.com">www.ellaforspam.com</a></font></td> </tr> </tbody> </table> </blockquote> </blockquote> </body> </html> --------------030503080109060305010003-- sending to informix-list |