Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to send input to a running process through terminal?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
naddahere
n00b
n00b


Joined: 13 Aug 2005
Posts: 25

PostPosted: Sun Jul 22, 2007 6:20 am    Post subject: How to send input to a running process through terminal? Reply with quote

I want to send input through a script, program, or terminal to a running process or an X window after its been started. Specifically this process is epsxe, a ps1 emulator. I was thinking I might be able to do this with echo, but I have no idea how to do this.
Thanks in advance
Back to top
View user's profile Send private message
vad3r
Guru
Guru


Joined: 02 May 2004
Posts: 461
Location: Munich, Germany

PostPosted: Tue Jul 24, 2007 9:36 am    Post subject: Reply with quote

I don't have any experience with epsxe. Does this process read input from STDIN? If it does you could try the following:

Code:
# mkfifo /path/epsxe.pipe
# epsxe < /path/epsxe.pipe &
# echo "This a a task" > /path/epsxe.pipe


This may work.
Back to top
View user's profile Send private message
naddahere
n00b
n00b


Joined: 13 Aug 2005
Posts: 25

PostPosted: Tue Jul 24, 2007 7:06 pm    Post subject: Reply with quote

No, it doesn't seem to support stdin. Is there a way to redirect program input from keyboard to console? or send console output to keyboard?
Thanks so much!
Back to top
View user's profile Send private message
vad3r
Guru
Guru


Joined: 02 May 2004
Posts: 461
Location: Munich, Germany

PostPosted: Wed Jul 25, 2007 9:09 am    Post subject: Reply with quote

Console output to keyboard would be rather strange. You should forget that.

If you use the example i provided to you the input get's redirected from keyboard to STDIN. Have you tried to run the app as suggested?
Back to top
View user's profile Send private message
naddahere
n00b
n00b


Joined: 13 Aug 2005
Posts: 25

PostPosted: Wed Jul 25, 2007 9:46 am    Post subject: Reply with quote

Yea, but epsxe still responds to keyboard and ignores STDIN.
Back to top
View user's profile Send private message
vad3r
Guru
Guru


Joined: 02 May 2004
Posts: 461
Location: Munich, Germany

PostPosted: Wed Jul 25, 2007 9:52 am    Post subject: Reply with quote

I tested the example i wrote earlier with a simple perl script. It works very well. If you started expse as expected there should be no way for the process to get your keyboard typings. Only if you use the pipe. Can you please post your terminal output?
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9546
Location: beyond the rim

PostPosted: Thu Jul 26, 2007 4:13 am    Post subject: Reply with quote

vad3r wrote:
I tested the example i wrote earlier with a simple perl script. It works very well. If you started expse as expected there should be no way for the process to get your keyboard typings. Only if you use the pipe.

There are many ways to get keyboard input without using stdin, like ncurses or X11.
Back to top
View user's profile Send private message
TerraN0va
n00b
n00b


Joined: 02 May 2004
Posts: 12

PostPosted: Mon Jul 30, 2007 8:47 am    Post subject: Reply with quote

epsxe is a X11 application, so it probably gets its keyboard input from X instead of ever reading your pipe. You need a program to "inject" keystroke events to epsxe.

I knew i had something like this once upon a time, but sadly can't quite remember what it was.
Back to top
View user's profile Send private message
manaka
Apprentice
Apprentice


Joined: 23 Jul 2007
Posts: 178
Location: Spain

PostPosted: Tue Jul 31, 2007 8:01 pm    Post subject: Reply with quote

You need a program that reads from stdin and interacts with the X server (which will send the keystrokes to the application)...

You can try xautomation (x11-misc/xautomation)... You can type something like this in a X terminal...
Code:

xte -x localhost:0 <<EOF
sleep 20
str Hello, world
EOF


Then make sure your desired window gets focus... And it will receive the keystrokes...

Maybe it's not what you exactly want... But it's close, I think...

Javi.
_________________
Javier Miqueleiz

"Listen to your heart. It knows all things, because it came from the Soul of the World, and it will one day return there."
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum