PDA

View Full Version : Can't start other process from "gnome-terminal", started by "execv".



lemik
December 3rd, 2011, 06:58 PM
Hello, i tried to start other process from "gnome-terminal" as it's written in "help":
gnome-terminal -e "other_program".
From terminal, manually, it works well - starts new window with "gnome-terminal" in it and executes the "other_program" in this new window.
Then I tried to start it from code:

.............
pid_t child_pid;
char* pArgv [] = {"-e", "other_program", NULL};
................
child_pid = fork();
if ( 0 == child_pid )
{
execvp ( "gnome-terminal", pArgv );
}
...........
After execution this line I have new open window for "gnome-terminal", but "other_program" did not executed.
I tried different versions of the "exec" functions, but without success.
What I do wrong? How can I start new terminal window and execute some program in it from C-code?
Than you in advance.

Arndt
December 3rd, 2011, 09:15 PM
Hello, i tried to start other process from "gnome-terminal" as it's written in "help":
gnome-terminal -e "other_program".
From terminal, manually, it works well - starts new window with "gnome-terminal" in it and executes the "other_program" in this new window.
Then I tried to start it from code:

.............
pid_t child_pid;
char* pArgv [] = {"-e", "other_program", NULL};
................
child_pid = fork();
if ( 0 == child_pid )
{
execvp ( "gnome-terminal", pArgv );
}
...........
After execution this line I have new open window for "gnome-terminal", but "other_program" did not executed.
I tried different versions of the "exec" functions, but without success.
What I do wrong? How can I start new terminal window and execute some program in it from C-code?
Than you in advance.

The first (zeroth) element in argv is supposed to be the name of the program. Try with


char* pArgv [] = {"gnome-terminal", "-e", "other_program", NULL};

lemik
December 3rd, 2011, 09:39 PM
Thanks a lot! It works!!!=D>

lemik
January 6th, 2012, 08:57 PM
Now I tried to set title to new-oped window by option: "--title=MyTitle"
.............
pid_t child_pid;
char* pArgv [] = {"-e", "other_program", "--title=MyTitle", NULL};
................
child_pid = fork();
if ( 0 == child_pid )
{
execvp ( "gnome-terminal", pArgv );
}
...........

and new title is not set :confused:

How can I open new terminal window with my title?
Thank you in advance.

ofnuts
January 6th, 2012, 09:09 PM
Now I tried to set title to new-oped window by option: "--title=MyTitle"
.............
pid_t child_pid;
char* pArgv [] = {"-e", "other_program", "--title=MyTitle", NULL};
................
child_pid = fork();
if ( 0 == child_pid )
{
execvp ( "gnome-terminal", pArgv );
}
...........

and new title is not set :confused:

How can I open new terminal window with my title?
Thank you in advance.


char* pArgv [] = {"-e", "other_program", "--title", "MyTitle", NULL};

(likely)

lemik
January 6th, 2012, 09:22 PM
Does not work: I get a message:
"Failed to parse arguments: Unknown option --titleMyTitle".

Sorry, I forgot "," after "--title".

It was: char* pArgv [] = {"-e", "other_program", "--title" "MyTitle", NULL};

But any way:

char* pArgv [] = {"-e", "other_program", "--title", "MyTitle", NULL};

does not display new title.

lemik
January 6th, 2012, 09:39 PM
Actually, for a half of second I can see the new title, but it instantly changes to directory, that I start process from.