[futurebasic] Re: [FB] Non-pascal string version of Open "Unix"

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2010 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 14 Jun 2010 05:47:34 -0400
Just ran the following through Brian's code as a test and it worked 
great on my PPC G4. I would suggest Open Unix fed with CFStrings be 
included as a part of FB in addition to the current one fed with 
Pascal strings.

Ken

p.s. I do fear that escaped characters in this code example may not 
make it through to the FB list.


dim as CFStringRef   s
dim as pointer       unixPipe
dim as CFMutableStringRef  mutStr

mutStr = fn CFStringCreateMutable ( _kCFAllocatorDefault, 0 )

CFStringAppend( mutStr, @"echo ""Here's a simple script:

""" )
CFStringAppend( mutStr, @"Hello, $USER
" )
CFStringAppend( mutStr, @"echo ""
Today's date is `date`, this is 
week `date +""%V""`.

""" )
CFStringAppend( mutStr, @"""This is `uname -s` running on a `uname 
-m` processor.

""" )
CFStringAppend( mutStr, @"""This is the uptime information:

""" )
CFStringAppend( mutStr, @"`uptime`" )
CFStringAppend( mutStr, @"""

Here is some information about your 
system:

""" )
CFStringAppend( mutStr, @"`sw_vers`" )
CFStringAppend( mutStr, @"""

Here is some information about 
apple.com:

""" )
CFStringAppend( mutStr, @"`dig apple.com | tr '
' '
'`" )
CFStringAppend( mutStr, @"""

Here is some information about disk 
usage:

""" )
CFStringAppend( mutStr, @"`df | tr '
' '
'`" )
/*
The following may take several minutes to run.
(Spinning pizza wheel will be displayed while running.)

CFStringAppend( mutStr, @"""

Here is some information about your 
system:

""" )
CFStringAppend( mutStr, @"`system_profiler | tr '
' '
'`" )
*/

unixPipe = fn PipeOpen( mutStr )
long if ( unixPipe )
s = fn GetCFStringResult( unixPipe )
fn HIViewSetText( sConsoleHITextView, s )
CFRelease( s )
end if
print
print "mutStr contains"; fn CFStringGetLength( mutStr ); " characters"
CFRelease( mutStr )

RunApplicationEventLoop()