You are not logged in.

#1 2009-09-10 17:54:56

pepeapepepe
Member
From: Buenos Aires, Argentina
Registered: 2009-05-13
Posts: 36

Sending Characters to a process

Hi,

    I'm trying to stop (nicely) a xterm running a ncmpc from another termial. For scrpiting purposes.

   So i thought it would be enought to send a 'q' character trought stdin.

   this is what i'm testing

pc -C ncmpc   # to grab the PID

once i've got the PID i try

echo -n q > /proc/PID/fd/0

but the progrma doesn't exits. (it prints the q on stdout)

Could somebody give advice on how to do this?

  1) is this the best way ?(maybe kill -STOP PID is not bad if ncmpc handles it well)

  2) or how do i echo the q?

regards


.--.-.... --. .-.-.-..-.-..--....- .- .-...-... --..-..-... -.-.----. ..-.. ...------....-...-.-----..-- .-....---.-..- --. .-.-.-..-.-.--- .-...-... --..-..-... -.-.----. .-...- -......-...-...-..-..-

Offline

#2 2009-09-11 03:10:14

giddygiddyBA
Member
From: Montreal
Registered: 2004-12-30
Posts: 66

Re: Sending Characters to a process

I asked a question similar to this awhile ago

http://bbs.archlinux.org/viewtopic.php?id=36103

For scripting you are better off to kill based on a PID (its cleaner to code, works every time, and more portable then the other option)

I am still interested if the redirect would work, you may want to post on a BSD forum as well (those folks have a wealth of knowledge as well)

Offline

Board footer

Powered by FluxBB