Hi Ivan,
Some quick remarks about networking.
-- Using telnet to access the cogserver is wild technology overkill.
Telnet was designed to provide a teletype terminal over the network,
including lots of complex teletype escape sequences. The cogserver
needs exactly zero of that.
-- the cogserver network interface is extremely low-level. So
low-level, you can't get any lower. It's rock-stupid simple and basic.
You open a socket. A very basic, simple, plain ordinary socket. Then
you read and write characters to it. That's all. That's it. It's not
any harder than opening a file, and reading/writing to that. Uses the
same read/write API that files use. If you know sockets well (and it
seems very few people do) it's about 5-10 lines of code. Or less.
There's absolutely no need for complexity.
I don't know php well enough, but the pseudocode really should be
```
sock = open (locahost, 17001)
write (sock, "(+ 2 2)")
read(sock, buffer)
close(sock)
```
Really little or nothing more than that..
FWIW, that's my coding philosophy: remove as much complexity as
possible ("but no more"). Kind of everything is guided by that.
Linas
On Mon, Dec 20, 2021 at 6:05 PM Ivan V. <[email protected]> wrote:
>
> I was thinking more in a direction of including some MIT licensed php telnet
> library. If I'm on the right path about this, then there is no need for
> installing netcat, "only" php and Apache web server. But from your examples,
> netcat command prompt seems pretty simple to use. I'm still not sure about
> php running native programs, especially receiving an output from them,
> including running the whole app directly from the web.
>
> - ivan -
>
> pon, 20. pro 2021. u 23:22 Linas Vepstas <[email protected]> napisao je:
>>
>> And one more, I hit send too soon.
>>
>> echo -e "scm quiet\n(+ 2 2)\n" |nc -N localhost 17001
>>
>> The "quiet" mode suppresses the printing of the guile prompts.
>> Unfortunately, the first prompt is always sent :-(
>>
>> -- linas
>>
>> On Mon, Dec 20, 2021 at 4:15 PM Linas Vepstas <[email protected]> wrote:
>> >
>> > Shoot. I wrote the wrong thing.
>> > Try this:
>> >
>> > echo "(+ 2 2)" |nc -N localhost 17001
>> >
>> > The -N flag closes the socket after getting the reply, otherwise it
>> > hangs waiting for more input.
>> > So you'd replace the echo by php print and pipe to command.
>> >
>> > -- Linas
>> >
>> > On Mon, Dec 20, 2021 at 4:10 PM Linas Vepstas <[email protected]>
>> > wrote:
>> > >
>> > > On Mon, Dec 20, 2021 at 3:39 PM Ivan V. <[email protected]> wrote:
>> > > >
>> > > > Ok, this was fun...
>> > > >
>> > > > I restarted the computer in the meanwhile, deleted the whole OpenCog,
>> > > > and recloned and rebuilt everything without any problems. This time I
>> > > > put all the additional assets I needed like cogserver under `opencog`
>> > > > directory, if that means anything.
>> > >
>> > > You should be able to `git clone` to anywhere at all. And after
>> > > building, saying `sudo make install` puts everything under the
>> > > `/usr/local` directory.
>> > >
>> > > My guess is that you had old and incompatible clones: you would have
>> > > to say `git pull` in all repos, to get a self-consistent version.
>> > >
>> > > > Cogserver is now up and running on port 17001, successfully
>> > > > communicating to rlwrap telnet. The initial test went fine.
>> > > >
>> > > > Next, the plan is to telnet it from php, and pipe it to html
>> > > > visualizer, if that's ok.
>> > >
>> > > probably the simplest way to do this is by wrapping php around netcat.
>> > > Warning, there are two incompatible versions of netcat you can
>> > > install. They are *almost* compatible, but not quite; one needs an
>> > > extra flag that the other doesn't, else it hangs up too soon.
>> > >
>> > > I have the bsd version installed the package is `netcat-openbsd`
>> > >
>> > > Use it like so: `nc localhost 17001 (+ 2 2)` or `nc localhost 17001
>> > > (cog-prt-atomspace)` and so on.
>> > >
>> > > > Wish me luck :)
>> > >
>> > > Good luck! and Merry Christmas, too!
>> > >
>> > > -- linas
>> > >
>> > > >
>> > > > - ivan -
>> > > >
>> > > > pon, 20. pro 2021. u 20:00 Linas Vepstas <[email protected]>
>> > > > napisao je:
>> > > >>
>> > > >> On Sun, Dec 19, 2021 at 2:11 PM Ivan V. <[email protected]> wrote:
>> > > >> >
>> > > >> > Hi Linas and others,
>> > > >> >
>> > > >> > Sorry for the delay, I've been busy with my other projects. Now I
>> > > >> > tried to install OpenCog, made through several make steps until my
>> > > >> > machine started to hang. Tried several times, it always hangs on
>> > > >> > the same build step. I guess this is a penalty for having only 4GB
>> > > >> > on my machine, right?
>> > > >>
>> > > >> It builds just fine on my six-year-old 1GB laptop (which cost $200
>> > > >> when new, so low end from the get-go.). I can even browse the web
>> > > >> while it's building.
>> > > >>
>> > > >> Open a bug report. describe the problem.
>> > > >>
>> > > >> > And then I tried another option: I installed OpenCog from here:
>> > > >> > `https://github.com/opencog/docker`. I tried to follow `README.md`
>> > > >> > instructions, ran `./docker-build.sh -a` (the script successfully
>> > > >> > completed), but then I got stuck starting cogserver because the
>> > > >> > `cogserver/build/` folder is empty.
>> > > >>
>> > > >> The docker containers are possibly stale.
>> > > >>
>> > > >> --linas
>> > > >>
>> > > >> --
>> > > >> You received this message because you are subscribed to the Google
>> > > >> Groups "opencog" group.
>> > > >> To unsubscribe from this group and stop receiving emails from it,
>> > > >> send an email to [email protected].
>> > > >> To view this discussion on the web visit
>> > > >> https://groups.google.com/d/msgid/opencog/CAHrUA34a2O624WCfk821t3wqUEYeg0WM%2B571AOKxGG2cCUB_xA%40mail.gmail.com.
>> > > >
>> > > > --
>> > > > You received this message because you are subscribed to the Google
>> > > > Groups "opencog" group.
>> > > > To unsubscribe from this group and stop receiving emails from it, send
>> > > > an email to [email protected].
>> > > > To view this discussion on the web visit
>> > > > https://groups.google.com/d/msgid/opencog/CAB5%3Dj6WYVbV14e4xZPWYJm-iEnzNdi21YXQK%2BbmWRa5f%2B29j4w%40mail.gmail.com.
>> > >
>> > >
>> > >
>> > > --
>> > > Patrick: Are they laughing at us?
>> > > Sponge Bob: No, Patrick, they are laughing next to us.
>> >
>> >
>> >
>> > --
>> > Patrick: Are they laughing at us?
>> > Sponge Bob: No, Patrick, they are laughing next to us.
>>
>>
>>
>> --
>> Patrick: Are they laughing at us?
>> Sponge Bob: No, Patrick, they are laughing next to us.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "opencog" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/opencog/CAHrUA35jXYy0AgLtum%3DvynpN%3DjvTH0r%2Bv5NPnBWncMVAxaKjtw%40mail.gmail.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/CAB5%3Dj6XaSAiommr7aLKHs880h7G_yEY0Nx2QKTismCoZRzw9nw%40mail.gmail.com.
--
Patrick: Are they laughing at us?
Sponge Bob: No, Patrick, they are laughing next to us.
--
You received this message because you are subscribed to the Google Groups
"opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/opencog/CAHrUA37G6CUQrdHQpwMS%3DkmM3StUZNCrUrmsVohr-sd51ZSsgA%40mail.gmail.com.