How to send a key event to another process?

M

Mirxon

Hello,
I'm working on a C program under Ubuntu.
It's basd on socket.
Browser calls a client cgi (C program), and send some parameters to
server (C program).
Server runs another program (ooimpress, open office ppt), and
translate the commands from client to a key event, and send it to
child process.

For example.
first, after openning xxx.odp on server, I need to display it in "full
screen mode", so I need to send "F5" from server program to child
process "ooimpress".

Now, I need to send F5, ESC, char n, and char p. and
I open the child process by using pipe (popen), and I send (fputc) the
command key to the pipe.......

But I cannot get the correct result......The ppt doesn't respond
anything......


My question is,
1, if I can implement this under pipe, how should I do,
2, if I cannot implement this under pipe, how should I do.

My main goal is open ooimpress, and control it to show next, previous
slide, esc, and full screen (F5 is hotkey for that).

Thanks a lot!!

Patrick
 
K

Keith Thompson

I'm working on a C program under Ubuntu.
It's basd on socket.
Browser calls a client cgi (C program), and send some parameters to
server (C program).
Server runs another program (ooimpress, open office ppt), and
translate the commands from client to a key event, and send it to
child process.
[snip]

There's no way to do this in standard C. Try comp.unix.programmer, or
perhaps a Linux or Ubuntu forum.
 
J

Jens Thoms Toerring

I'm working on a C program under Ubuntu.
It's basd on socket.

Sorry, but you will be in for a bad surprise, sockets (and
networking at all) aren't part of the C language, they are
deal with (often system specific libraries).
Browser calls a client cgi (C program), and send some parameters to
server (C program).

Hmm, a browser doesn't call a "client cgi". A browser may
send a request to a HTTP server which, in turn, may invoke
a CGI script/program (written in whatever language, but you
will find that it's rarely C).
Server runs another program (ooimpress, open office ppt), and
translate the commands from client to a key event, and send it to
child process.

Why should the HTTP server run such a program? Many servers
may run all day without even screen attached, so running one
of those programs will be rather futile.
For example.
first, after openning xxx.odp on server, I need to display it in "full
screen mode", so I need to send "F5" from server program to child
process "ooimpress".

Sorry, but I guess you've got a lot of things mixed up here.
Now, I need to send F5, ESC, char n, and char p. and
I open the child process by using pipe (popen), and I send (fputc) the
command key to the pipe.......

Now you seem to be talking about two processes on a UNIX-
like platform. That doesn't fit too well with the browser
(client) and HTTP server things you wrote about before.
Just note that pipes and the popen() function are POSIX
terms, they have no real meaning when it comes to the
language C.
But I cannot get the correct result......The ppt doesn't respond
anything......

I guess you're trying something with certain programs that
are installed on your machine. But from a language point of
view C doesn't support networking by any built-in functions,
it doesn't have a native popen() function (or anything for
pipes) and definitely doesn't have any special built-in support
for dealing with program like "ooimpress" or "open office".
My question is,
1, if I can implement this under pipe, how should I do,
2, if I cannot implement this under pipe, how should I do.
My main goal is open ooimpress, and control it to show next, previous
slide, esc, and full screen (F5 is hotkey for that).

I find it difficult to come up with proposals where you should
ask since you mix too many unrelated things into a single
question. So a few tentative suggestions: if you have problems
with pipes and popen() ask in comp.unix.programmer, that's where
the experts for these functions can be found. Regarding control-
ling some kind of parts from the open office suite from another
program I am a bit at a loss, but there should be quite a number
of mailing lists, web forums etc. that are suitable for these
kind of questions (but I can't tell you were they are since I
never had to have to deal with that). And about the browser/HTTP
stuff you started of with I can only recommend to relax, take a
good look at what exactly you are trying to do and formulate it
in a somewhat more clear language that takes into account how
browsers and HTTP servers interact and what is happening on
both sides. Perhaps the first step you should take is to write
a clear description of what you intend to do, not already in-
sisting of the ways to do it. That may clear up the way to a
workable solution a lot. Write down what you want to, not mixing
it up with how to do it, and you may come up with a question that
can be answered (although not completely or even in parts here
in clc).

Regards, Jens
 
M

Mirxon

Hi guys, thanks a lot for all your replies.

Seems I need to move my question to unix group :)

Thanks again for the hearty reply.

Good Luck~~

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top