[Gambas-user] hProcess is NULL

Demosthenes Koptsis demosthenesk at ...626...
Mon Dec 27 12:00:12 CET 2010


if i use

SHELL sCommand to sVar

i have to wait to complete execution of command. Right?

In my case 
hProcess1 = SHELL sCommand FOR INPUT AS "AntiVirRun"

sCommand is a scan command of an antivirus for 9000 files and more...

This takes almost 10 minutes or more to be completed.

i want in these 10 minutes to read the stdout from this sCommand because
i get messages for each file if it is cleaned or has a virus.

if i used
hProcess1 = SHELL sCommand WAIT FOR INPUT AS "AntiVirRun"

it wont work, i cant process AntiVirRun_Read

the same is for
SHELL sCommand to sVar.

So i wanted a way to stop executiono program for the time the sCommand
is executed and also to process AntiVirRun_Read

this is worked with

 hProcess1 = SHELL sCommand FOR INPUT AS "AntiVirRun"
 WHILE (hProcess1.Running)
  WAIT 10
 WEND



On Mon, 2010-12-27 at 11:34 +0100, Fabien Bodard wrote:
> Exec ["ls", "-a"] to sLig
> 
> Print sLig
> 
> 
> To do what you want .... it's enought
> 
> 2010/12/27 Fabien Bodard <gambas.fr at ...626...>:
> > 2010/12/27 Demosthenes Koptsis <demosthenesk at ...626...>:
> >> Well i found a way
> >>
> >>
> >> hProcess1 = SHELL sCommand FOR INPUT AS "AntiVirRun"
> >> WHILE (hProcess1.Running)
> >>  WAIT 10
> >> WEND
> >>
> >
> > ?????? what is that ?
> >
> >
> >
> >> yes there is a reason because i want to stop execution of next lines but
> >> i cant explain it right now.
> >>
> >> So with this code i can process _Read event of process and stop
> >> execution of code.
> >>
> >> Anyway thank you all for the help.
> >>
> >>
> >> On Mon, 2010-12-27 at 10:36 +0100, Ron wrote:
> >>> Not clear why you want to wait exactly, but another way is not to wait
> >>> but to continue when process is finished.
> >>>
> >>> AntiVirRun_Kill() is called when process is finished.
> >>> So you can do other things in meantime (like parsing _Read) and call
> >>> the code to run from _Kill to continue.
> >>>
> >>> See here for some code:
> >>> http://www.domotiga.nl/browser/trunk/DomotiGa/Ping.module
> >>>
> >>> Regards,
> >>> Ron_2nd.
> >>> On Mon, Dec 27, 2010 at 10:21 AM, Ian Haywood <ihaywood at ...1979...> wrote:
> >>> > On Mon, Dec 27, 2010 at 8:11 PM, Demosthenes Koptsis
> >>> > <demosthenesk at ...626...> wrote:
> >>> >> On Mon, 2010-12-27 at 10:20 +1100, Ian Haywood wrote:
> >>> >>> On Mon, Dec 27, 2010 at 4:46 AM, Demosthenes Koptsis
> >>> >>> <demosthenesk at ...626...> wrote:
> >>> >>> > Hello and merry Christmas,
> >>> >>> >
> >>> >>> > i have these lines of code
> >>> >>> >
> >>> >>> > -----------
> >>> >>> >  sCommand = "/opt/avast4workstation-1.3.0/bin/avast -r " &
> >>> >>> > txtVirusTempFolder.Text & "/avast-report.txt" & " -ac -t A " &
> >>> >>> > txtVirusTempFolder.Text
> >>> >>> >
> >>> >>> >  PRINT sCommand
> >>> >>> >
> >>> >>> >  hProcess1 = SHELL sCommand WAIT FOR INPUT OUTPUT AS "AntiVirRun"
> >>> >>> > -----------
> >>> >>> >
> >>> >>> > After that line the hProcess1 is NULL and i get NULL object in
> >>> >>> >
> >>> >>> > PUBLIC SUB AntiVirRun_Read()
> >>> >>> Drop the "WAIT" keyword.
> >>> >>
> >>> >> Actually i want the WAIT word.
> >>> >>
> >>> >> I want to WAIT until the command is finished but in meanwhile i want to
> >>> >> be capable to read the stdout.
> >>> > Use Shell...To as I described.
> >>> > Or read output and then when you are finished reading use hProcess.Wait()
> >>> >
> >>> > But you can't wait and read at the same time.
> >>> >
> >>> > Ian
> >>> >
> >>> > ------------------------------------------------------------------------------
> >>> > Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> >>> > to consolidate database storage, standardize their database environment, and,
> >>> > should the need arise, upgrade to a full multi-node Oracle RAC database
> >>> > without downtime or disruption
> >>> > http://p.sf.net/sfu/oracle-sfdevnl
> >>> > _______________________________________________
> >>> > Gambas-user mailing list
> >>> > Gambas-user at lists.sourceforge.net
> >>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>> >
> >>>
> >>> ------------------------------------------------------------------------------
> >>> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> >>> to consolidate database storage, standardize their database environment, and,
> >>> should the need arise, upgrade to a full multi-node Oracle RAC database
> >>> without downtime or disruption
> >>> http://p.sf.net/sfu/oracle-sfdevnl
> >>> _______________________________________________
> >>> Gambas-user mailing list
> >>> Gambas-user at lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >> --
> >> Regards,
> >> Demosthenes Koptsis.
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> >> to consolidate database storage, standardize their database environment, and,
> >> should the need arise, upgrade to a full multi-node Oracle RAC database
> >> without downtime or disruption
> >> http://p.sf.net/sfu/oracle-sfdevnl
> >> _______________________________________________
> >> Gambas-user mailing list
> >> Gambas-user at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >
> >
> >
> > --
> > Fabien Bodard
> >
> 
> 
> 

-- 
Regards,
Demosthenes Koptsis.





More information about the User mailing list