Re: Passing a value from Unix into 4GL ?
Posted in 2004
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:DirkM@mxgroup.co.za> > 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.com.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: norma