New topic: 

Asynchronous Shell in Console App

<http://forums.realsoftware.com/viewtopic.php?t=46349>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        capaho          Post subject: Asynchronous Shell in Console 
AppPosted: Tue Dec 25, 2012 9:13 pm                         
Joined: Fri Jul 21, 2006 12:28 am
Posts: 479                I have a console app that uses shell commands that I 
have been using for several years without problem until I made a minor revision 
to the code and a new build using 2012r2.  The 2012r2 build results in the 
following error being recorded in the system logs:
Quote:Untrusted apps are not allowed to connect to or launch Window Server 
before login.
I don't know why the app is now trying to launch a window when it didn't 
previously as there is nothing in the code that calls for a window.  In any 
case, I 
decided to run it in asynchronous mode to see if that resolved the problem but 
sh.ReadAll does not return any data.  This works in synchronous mode:
Dim sh As New Shell
Dim s As String
sh.Mode = 0
sh.Execute "tail -n 20 /var/log/system.log"
s = sh.Result
print s
sh.Close

This does not work in asynchronous mode:
Dim sh As New Shell
Dim s As String
sh.Mode = 1
sh.Execute "tail -n 20 /var/log/system.log"
s = sh.ReadAll
print s
sh.Close

What am I missing?      
_________________
Regards,
Carl
Capaho Web
http://www.capaho.com  
                             Top                timhare          Post subject: 
Re: Asynchronous Shell in Console AppPosted: Tue Dec 25, 2012 11:45 pm          
               
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11913
Location: Portland, OR  USA                In synchronous mode, Execute waits 
for the command to complete, so you get your result.  In asynchronous mode, 
Execute returns immediately, so Result is blank on the next line because the 
shell hasn't done anything yet.  In async, get your result in the DataAvailable 
event.  And in a console app, you must code your own event loop or poll the 
shell.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to