From: no.top.post on
In article <T4mdnd7JJ_4yVb7WnZ2dnUVZ_uKdnZ2d(a)earthlink.com>, Steven J Masta <smasta(a)earthlink.net> wrote:

> no.top.post(a)gmail.com wrote:
> > I've got a nice system that run 'on top of' linux and which can
> > read/write linux files too. In order to still be able to see the other
> > system's display, instead of switching to linux when I 'run' some
> > simple linux commands I could perhaps eg.
> > 1. write to a 'known special' file: "ls /usr/*"
> > 2. which would, via some daeamon mechanism:
> > read the 'known special' file and execute
> > eg. "ls /usr/* > SpecialRetrnFile"
> > 3. read/display "SpecialRetrnFile"
> >
> > How could I implement the linux daemon mechanism ?
> > Or are their other more sophisticated but not too complex
> > methods of doing such client-server transactions?
> >
> A crude hack would be to create your own pipe using mkfifo. Write a
> script that "reads the pipe and executes the contents sending the output
> to SpecialRetrnFile" inside a loop. The read will wait until data is
> available.
>
> You have to send commands to the pipe by opening it write-only - that
> means you can't open it in a text editor - so you'd need to either use
> redirection
> echo 'ls /usr/*' > mypipe
> or create a new file in a text editor and then save it as mypipe.
>
> Steve

Let's investigate this !
info mkfifo ==
]A "FIFO" is a special file type that permits independent processes
]to communicate. One process opens the FIFO file for writing, and
]another for reading, after which data can flow as with the usual
]anonymous pipe in shells or elsewhere.

It will be great if writing & reading processes can be asyncronous.
So just controlled by some interrupt mechanism.
So that's down at the kernel-level where we don't want to go?!

-> try: mkfifo LEOpipe == no output
-> see if LEOpipe 'exists': lsof | grep pipe == many but no LEOpipe
-> if it HAS been created, how do you kill it ?
-> RE-try: mkfifo LEOpipe == ..File exists
-> ls -l LEOpipe ==? wow !
prw-r--r-- 1 root root 0 Dec 14 12:03 LEOpipe

-> echo 'ls /usr/*' > LEOpipe == na
BTW I'm running as 'root'

It's noted that: echo "ls" > <path>/LEOpipe in one VT : hangs
and then, in another VT the size is still 0.

I don't know enough about 'pipes' and linux to progress.

Please advise.

== TIA.


From: Grant on
On Mon, 14 Dec 2009 11:08:32 +0000 (UTC), no.top.post(a)gmail.com wrote:

>In article <T4mdnd7JJ_4yVb7WnZ2dnUVZ_uKdnZ2d(a)earthlink.com>, Steven J Masta <smasta(a)earthlink.net> wrote:
>
>> no.top.post(a)gmail.com wrote:
>> > I've got a nice system that run 'on top of' linux and which can
>> > read/write linux files too. In order to still be able to see the other
>> > system's display, instead of switching to linux when I 'run' some
>> > simple linux commands I could perhaps eg.
>> > 1. write to a 'known special' file: "ls /usr/*"
>> > 2. which would, via some daeamon mechanism:
>> > read the 'known special' file and execute
>> > eg. "ls /usr/* > SpecialRetrnFile"
>> > 3. read/display "SpecialRetrnFile"
>> >
>> > How could I implement the linux daemon mechanism ?
>> > Or are their other more sophisticated but not too complex
>> > methods of doing such client-server transactions?
>> >
>> A crude hack would be to create your own pipe using mkfifo. Write a
>> script that "reads the pipe and executes the contents sending the output
>> to SpecialRetrnFile" inside a loop. The read will wait until data is
>> available.
>>
>> You have to send commands to the pipe by opening it write-only - that
>> means you can't open it in a text editor - so you'd need to either use
>> redirection
>> echo 'ls /usr/*' > mypipe
>> or create a new file in a text editor and then save it as mypipe.
>>
>> Steve
>
>Let's investigate this !
>info mkfifo ==
>]A "FIFO" is a special file type that permits independent processes
>]to communicate. One process opens the FIFO file for writing, and
>]another for reading, after which data can flow as with the usual
>]anonymous pipe in shells or elsewhere.
>
>It will be great if writing & reading processes can be asyncronous.
>So just controlled by some interrupt mechanism.
>So that's down at the kernel-level where we don't want to go?!
>
>-> try: mkfifo LEOpipe == no output
>-> see if LEOpipe 'exists': lsof | grep pipe == many but no LEOpipe
>-> if it HAS been created, how do you kill it ?
>-> RE-try: mkfifo LEOpipe == ..File exists
>-> ls -l LEOpipe ==? wow !
>prw-r--r-- 1 root root 0 Dec 14 12:03 LEOpipe
>
>-> echo 'ls /usr/*' > LEOpipe == na
>BTW I'm running as 'root'
>
>It's noted that: echo "ls" > <path>/LEOpipe in one VT : hangs
> and then, in another VT the size is still 0.
>
>I don't know enough about 'pipes' and linux to progress.

Yet you think you need a daemon this xmas?
>
>Please advise.

Okay, open two terminals in your home dir, then...

first terminal:
$ mkfifo transfer
$ ls -l transfer
prw-r--r-- 1 grant users 0 2009-12-14 22:36 transfer|
$ ls > transfer

Second terminal:
$ cat transfer
Desktop/
bin/
canon/
....
sitemap/
src/
test/
transfer|

Easy! In one terminal and out the other :o)

Grant.
--
http://bugsplatter.id.au
From: Steven J Masta on
no.top.post(a)gmail.com wrote:
> In article <T4mdnd7JJ_4yVb7WnZ2dnUVZ_uKdnZ2d(a)earthlink.com>, Steven J Masta <smasta(a)earthlink.net> wrote:
>
>> no.top.post(a)gmail.com wrote:
>> > I've got a nice system that run 'on top of' linux and which can
>> > read/write linux files too. In order to still be able to see the other
>> > system's display, instead of switching to linux when I 'run' some
>> > simple linux commands I could perhaps eg.
>> > 1. write to a 'known special' file: "ls /usr/*"
>> > 2. which would, via some daeamon mechanism:
>> > read the 'known special' file and execute
>> > eg. "ls /usr/* > SpecialRetrnFile"
>> > 3. read/display "SpecialRetrnFile"
>> >
>> > How could I implement the linux daemon mechanism ?
>> > Or are their other more sophisticated but not too complex
>> > methods of doing such client-server transactions?
>> >
>> A crude hack would be to create your own pipe using mkfifo. Write a
>> script that "reads the pipe and executes the contents sending the output
>> to SpecialRetrnFile" inside a loop. The read will wait until data is
>> available.
>>
>> You have to send commands to the pipe by opening it write-only - that
>> means you can't open it in a text editor - so you'd need to either use
>> redirection
>> echo 'ls /usr/*' > mypipe
>> or create a new file in a text editor and then save it as mypipe.
>>
>> Steve
>
> Let's investigate this !
> info mkfifo ==
> ]A "FIFO" is a special file type that permits independent processes
> ]to communicate. One process opens the FIFO file for writing, and
> ]another for reading, after which data can flow as with the usual
> ]anonymous pipe in shells or elsewhere.
>
> It will be great if writing & reading processes can be asyncronous.
> So just controlled by some interrupt mechanism.
> So that's down at the kernel-level where we don't want to go?!
>
> -> try: mkfifo LEOpipe == no output
> -> see if LEOpipe 'exists': lsof | grep pipe == many but no LEOpipe
> -> if it HAS been created, how do you kill it ?
> -> RE-try: mkfifo LEOpipe == ..File exists
> -> ls -l LEOpipe ==? wow !
> prw-r--r-- 1 root root 0 Dec 14 12:03 LEOpipe
>
> -> echo 'ls /usr/*' > LEOpipe == na
> BTW I'm running as 'root'
>
> It's noted that: echo "ls" > <path>/LEOpipe in one VT : hangs
> and then, in another VT the size is still 0.
>
> I don't know enough about 'pipes' and linux to progress.
>
> Please advise.
>
> == TIA.

<lecture>
linux.dev.kernel dropped because it doesn't have anything to do with
this. This is also my last post on this subject - you really need to
learn more about scripting and system operations in general. I suggest
you start at http://www.tldp.org/LDP/abs/html/ (The Advanced Bash
Scripting Guide) then read everything else that http://www.tldp.org/ has
to offer.
</lecture>

# create a pipe - you might need to change permissions so your ETH
# Oberon user can write to it
% mkfifo mypipe
% ls -l mypipe
prw-r--r-- 1 smasta users 0 2009-12-14 11:28 mypipe|

# here is a simple "daemon" that does the work
# the code isn't pretty and there is no error checking
% ls -l DaemonHack.sh
-rwxr-xr-x 1 smasta users 103 2009-12-14 11:14 DaemonHack.sh*
% cat DaemonHack.sh
#!/bin/sh
while [ true ];
do
MYCMD=$(cat ./mypipe)
/usr/bin/bash -c "$MYCMD" > ./ResultsFile
done

# we now run the "daemon" and put it in the background with '&'
% ./DaemonHack.sh &
[1] 3549

# send the command 'ls /tmp' to the pipe
% echo 'ls /tmp' > mypipe

# read the results
% cat ResultsFile
4b223e507ec3f
4b223e51e414b
Packages
SciTE.3542.in
mc-smasta
nscopy.tmp
nsma
nsmail.eml
% echo 'ls -l /tmp' > mypipe
% cat ResultsFile
total 1120
-rw------- 1 smasta users 528409 2009-12-11 07:42 4b223e507ec3f
-rw------- 1 smasta users 528409 2009-12-11 07:42 4b223e51e414b
drwxr-xr-x 2 root root 4096 2009-11-25 14:59 Packages
prwxr-xr-x 1 smasta users 0 2009-12-14 11:27 SciTE.3542.in
drwx------ 2 smasta users 4096 2009-11-25 11:53 mc-smasta
-rw------- 1 smasta users 1261 2009-12-09 10:13 nscopy.tmp
-rw------- 1 smasta users 53248 2009-12-03 09:03 nsma
-rw------- 1 smasta users 1011 2009-12-09 10:13 nsmail.eml
% echo 'uname -a' > mypipe
% cat ResultsFile
Linux slink 2.6.29.6 #1 Mon Dec 7 16:34:06 CST 2009 i586 AMD-K6(tm) 3D+
Processor AuthenticAMD GNU/Linux
% echo 'ls -l /tmp/n*' > mypipe
% cat ResultsFile
-rw------- 1 smasta users 1261 2009-12-09 10:13 /tmp/nscopy.tmp
-rw------- 1 smasta users 53248 2009-12-03 09:03 /tmp/nsma
-rw------- 1 smasta users 1011 2009-12-09 10:13 /tmp/nsmail.eml

# bring the "daemon" to the forground and kill it
% fg
[1] + running ./DaemonHack.sh
^C
%


Steve
From: Henrik Carlqvist on
no.top.post(a)gmail.com wrote:
> Let's investigate this !

Something new and unknown can be worth investigating.

> info mkfifo ==
> ]A "FIFO" is a special file type that permits independent processes ]to
> communicate. One process opens the FIFO file for writing, and ]another
> for reading, after which data can flow as with the usual ]anonymous pipe
> in shells or elsewhere.

A rather good description of what mkfifo does. However, maybe it should be
noted that mkfifo itself doesn't create any processes. Mkfifo only creates
a named pipe which looks like a file, you are then responsible to create
any processes that will use the fifo.

> -> try: mkfifo LEOpipe == no output

You have just created a special kind of file which acts as a named pipe,
there should be no output here.

> -> see if LEOpipe 'exists': lsof | grep pipe == many but no LEOpipe

It seems as if you don't really know what is going on or what you are
doing. Maybe you should try some googling before doing more experiments.

> -> if it HAS been created, how do you kill it ?

Named pipes, like files, are not killed, they are removed with rm.

> -> RE-try: mkfifo LEOpipe == ..File exists -> ls -l LEOpipe ==? wow !
> prw-r--r-- 1 root root

So you found it :-)

> -> echo 'ls /usr/*' > LEOpipe == na

You now have one process which has written to the fifo. All you need is
another process to read from the fifo.

> BTW I'm running as 'root'

As you obviosly have no idea what you are doing I would say running as
root is an extremely bad habit. Do you play with chainsaws and dynamite
to without understanding what it does? It is only a matter of time before
you will have messed up your machine completely. Please disconnect all
your machines from internet, I don't want to be connected to the same
internet as machines operated by such a maniac. Also if you play with
dynamite I hope you don't live near my house.

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc3(at)poolhem.se Examples of addresses which go to spammers:
root(a)localhost postmaster(a)localhost