터미널 실행후 터미널에 명령 실행시키기...

luftpalen의 이미지

네 제목대로 터미널을 실행후 그 터미널에 제가 플그래밍한 것을 실행시킨다음 터미널을 닫으려고 합니다...

아... 비줠C++ 에서 c 파일 execute 하는것하고 비슷한것 같네요.

fork() 써서 gnome-terminal 을 띄우는것 까지는 좋았는데, 그 터미널에다 제가 만든 플그래밍을 실행시키고 닫는게 힘드네요 -_-;;

조언 부탁드립니다~

cinsk의 이미지

$ gnome-terminal -e PROGRAM_NAME ARG...

mc로 다음과 같이 테스트 가능..

$ gnome-terminal -e mc

특별한 이유가 있다면 모를까, 이런 목적으로는 다양한 제어가 가능한? xterm을 쓰는 게 좋을 것 같습니다.

ganadist의 이미지

libgnome 의 gnome-exec.h 에 정의된 아래 함수들을 쓰면 그놈의 터미널 설정에 맞는 터미널 프로그램 내에서 명령을 수행합니다.

/**
 * gnome_execute_terminal_shell_fds:
 * @dir: Directory in which child should be executed, or %NULL for current
 *       directory
 * @commandline: Shell command to execute
 * @close_fds: Like close_fds in gnome_execute_async_with_env_fds()
 *
 * Description:  Like gnome_execute_shell_fds(), except that it runs the
 * terminal as well.  Note that the pid of the terminal is
 * returned, not the pid of the user's program.
 * If commandline is %NULL, just the shell is run.
 *
 * Returns: process id of terminal, or %-1 on error.
 **/
int
gnome_execute_terminal_shell_fds (const char *dir, const char *commandline,
                  gboolean close_fds)

/**
 * gnome_execute_terminal_shell:
 * @dir: Directory in which child should be executed, or NULL for current
 *       directory
 * @commandline: Shell command to execute
 *
 * Description:  Like #gnome_execute_async, except that it runs the
 * terminal as well.  Note that the pid of the terminal is
 * returned, not the pid of the user's program.
 * If commandline is %NULL, just the shell is run.
 *
 * Returns: process id of terminal, or %-1 on error.
 **/
int
gnome_execute_terminal_shell (const char *dir, const char *commandline)

----
데스크탑 프로그래머를 꿈꾸는 임베디드 삽질러