2011-03-21 2 views
0

명령 줄 프로그램이 명령 줄과 상호 작용하는 백그라운드 스레드 (예 : ./program &)로 실행되는 경우 어떻게 명령을 보낼 수 있습니까? 명령 줄에 입력되는 것처럼 문자를 보내는 방법 (예 : 'pipe'사용)이 있습니까?배경 응용 프로그램에 키 누르기 보내기

단순화 명령 줄 예 :

(일반적인 경우) & 없음 : &와

~/home/temp> ./testprogram 

~/home/temp> Welcome to Testprogram. Enter command: 

~/home/temp> Welcome to Testprogram. Enter command: quit 

~/home/temp> Goodbye! 

:

~/home/temp> ./testprogram & 

~/home/temp> Welcome to Testprogram. Enter command: 

~/home/temp> quit 

~/home/temp> Command not found. 

이 PS -e | (내 경우!) grep testprogram은 여전히 ​​실행 중이지만 이제는 kill 명령을 사용하여 종료 할 수 없습니다. 이상적 일 것이다 무엇

는 다음과 같이이다 :

나는이 정확히 어떻게해야합니까?

당신은 fg를 사용하여 다시 프로그램을 가져올 수

답변

0

: "하나 이상의 백그라운드로 작업을하는 경우

~/home/temp> ./testprogram & 
Welcome to Testprogram. Enter command: 
~/home/temp> ls /tmp # do whatever else you want to do on the shell 
# ... later 
~/home/temp> jobs  # what was running? 
[1]+ Running     ./testprogram & 
~/home/temp> fg  # Brings testprogram to foreground, does not re-prompt 
quit 
Goodbye! 
~/home/temp> 

, 당신은"FG % 2 "FG % 1"을 사용하여 포 그라운드로 선택할 수 있습니다 ...

주 : 작업을 중지 (Ctrl-z) 한 다음 쉘 프롬프트에서 bg를 입력하여 포 그라운드 된 작업을 백그라운드로 되돌릴 수 있습니다.

관련 문제