Re: [Pharo-project] Command Line Interface using FFI

classic Classic list List threaded Threaded
1 message Options
Eliot Miranda-2 Eliot Miranda-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [Pharo-project] Command Line Interface using FFI

 


On Tue, Jan 31, 2012 at 8:35 PM, S Krish <[hidden email]> wrote:
I cant get the stdin on FileStream to work. Just blocks irrespective of what I do in sending characters with enter.. or any other trials .. will check a little more

I assure you it does work with the right image-level code.  Here's an interaction with a 3.8/Qwaq derived image on Mac OS:

McStalker.macbuild$ uname -a
Darwin McStalker 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 i386
McStalker.macbuild$ oscfvm ~/Cog/startreader.image 
squeak> DateAndTime now!
2012-02-03T13:04:24-08:00
squeak> Smalltalk quit!
McStalker.macbuild$ 

On linux:
[eliot@mcqfes ~]$ oscogvm/coglinux/squeak Cog/startreader.image 
squeak> Smalltalk quit!
[eliot@mcqfes ~]$ uname -a
Linux mcqfes 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 EST 2009 i686 i686 i386 GNU/Linux
[eliot@mcqfes ~]$ oscogvm/coglinux/squeak Cog/startreader.image 
squeak> DateAndTime now!
2012-02-03T13:05:58-08:00
squeak> Smalltalk quit!
[eliot@mcqfes ~]$ 

And windows:
U:\Cog>ver

Microsoft Windows XP [Version 5.1.2600]

U:\Cog>oscogvm\cygwinbuild\build\vm\CroquetConsole.exe startreader.image
squeak> DateAndTime now!
2012-02-03T13:07:39-08:00
squeak> Smalltalk quit!

U:\Cog>

It's crude, using chunk format, but demonstrates the functionality and is very simple.  To get this to work requires the attached nextChunkNoTag hack since restoreState:with: seems unreliable (it implements skip: -1, which is used in peek).  For Windows you need the 2519 or newer Cog VM.



On Wed, Feb 1, 2012 at 5:06 AM, Eliot Miranda <[hidden email]> wrote:


On Tue, Jan 31, 2012 at 4:10 AM, Damien Pollet <[hidden email]> wrote:
On 29 January 2012 21:11, Guillermo Polito <[hidden email]> wrote:
> I've spent a few hours playing with Alien+FFI and I did want to have a
> Command line interface to play and use as a quick browser.

This is something I'd like to have as a part of Coral.

What's your opinion on the FFI-libc approach compared to OSProcess? I
was actually thinking of doing something like that using NativeBoost
:)

There is a third option which just uses the stdio streams in StandardFileStream.  this has been working in the Cog VMs for some time now.


> Gofer it
>     squeaksource: 'CLInterface';
>     package: 'ConfigurationOfCLInterface';
>     load.
>
> ConfigurationOfCLInterface load.
>
>
> To play with it write a script, for example startCLI.st, with the following:
>
> CLInterface start
>
>
>
> And then, from the command line
>
> CogVM -vm-display-null <image> startCLI.st
>
>
> What it does support?
> - executes smalltalk expressions
> - handles the errors and shows them into the stdout (so it does not explode
> :P)
> - stores variables as a workspace
> Since I used standard C functions (fgets and printf only) this should work
> on every platform from scratch (having a VM with FFI working, of course)...
>
> The problems I've ran so far:
> - blocking FFI blocks the vm.  I've not tried yet to use threads through FFI
> (and I don't know if it works.  Does it?).  But It should be great to start
> a headless seaside server with a command line :/.
>
> Ok, it's a very simple thing, but it allows to execute a expression from a
> remote server via ssh without doing much :).
>
> Guille



--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet




--
best,
Eliot





--
best,
Eliot


StdioListener.st (1K) Download Attachment
PositionableStream-nextChunkNoTag.st (1K) Download Attachment
Loading...