Re: Passing a value from Unix into 4GL ?
Posted in 2004
This is a multi-part message in MIME format. --------------080201090207060005020904 Content-Type: multipart/alternative; boundary="------------000607000808070808030703" --------------000607000808070808030703 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, I have attached two sample codes - retval.c ( this is c interface ) getval.4gl ( this is 4gl code which calls c code ) compile with c4gl getval.4gl retval.c -o getout to run , use getout FILENAME Please note that code does not have proper error handling etc etc. This is just for your information. Rgds Preetinder Francisco Roldan wrote: > It would be very useful if you send us an example of this > solution. > > Thanks in advance > > ----- Original Message ----- > From: Preetinder Dhaliwal <mailto:preetinder.dhaliwal@dhl.com> > To: Fernando Ortiz <mailto:fortiz@lacorona.com.mx> > Cc: Dirk Moolman <mailto:DirkM@mxgroup.co.za> ; > informix-list@iiug.org <mailto:informix-list@iiug.org> > 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=`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> >> --------------000607000808070808030703 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"> Hi,<br> <br> I have attached two sample codes -<br> retval.c ( this is c interface )<br> getval.4gl ( this is 4gl code which calls c code )<br> <br> compile with c4gl getval.4gl retval.c -o getout<br> <br> to run , use getout FILENAME <br> <br> Please note that code does not have proper error handling etc etc.<br> <br> This is just for your information.<br> <br> Rgds<br> Preetinder<br> <br> <br> Francisco Roldan wrote:<br> <blockquote type="cite" cite="mid008801c43f4f$484404c0$970a0a0a@froldan"> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <meta content="MSHTML 6.00.2600.0" name="GENERATOR"> <div><font face="Tahoma" size="2">It would be very useful if you send us an example of this</font></div> <div><font face="Tahoma" size="2">solution. </font></div> <div> </div> <div><font face="Tahoma" size="2">Thanks in advance</font></div> <blockquote dir="ltr" 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="preetinder.dhaliwal@dhl.com" href="mailto:preetinder.dhaliwal@dhl.com">Preetinder Dhaliwal</a> </div> <div style="font-family: arial; font-style: normal; fon