On Sun, Jan 25, 2009 at 8:16 AM, Wouter Bolsterlee <wbols...@gnome.org> wrote: > 2009-01-25 klockan 16:43 skrev Ignacio Butler: >> On Sun, Jan 25, 2009 at 8:58 AM, Wouter Bolsterlee <wbols...@gnome.org> >> wrote: >> > 2009-01-25 klockan 07:16 skrev Ignacio Butler: >> >> If I do >> >> vte_terminal_fork_command(w, "vim", NULL, NULL, ".", FALSE, FALSE, >> >> FALSE); >> >> Vim is executed and i can interact with it. But if I run a program >> >> like "ls", which ends after directory listing, no output is shown, no >> >> matter what I do. >> >> How I can show output of programs that ends? Is this behavior normal? >> > Perhaps the gnome-terminal code that provides the "do not close window when >> > command exits" behaviour can serve as inspiration for you. >> I've set gnome-terminal to run "ls ~/" instead shell and no close >> window after command exit and I had the same result: no output shown >> I'll try to implement this functionallity using pipes (or something >> like that) instead the vte. > > Another approach would be to execute a command like this in the VTE widget: > > sh -c "'YOUR COMMAND LINE GOES HERE'; read;" > > In this case the spawned shell will wait for the user to hit Enter (or > Ctrl-C or Ctrl-D) to exit. > >> Thanks for the advice! > > You're welcome. > > — Wouter > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: This message was signed/encrypted using GnuPG. > > iD8DBQFJfJBwP7QTTiUKY+sRAu3dAJ9yTjz8YTRsWfWDuJZ+H3qbjOuXGACgoosT > zpgl+x7eaw7QAsWbYl5Yoo0= > =vlqj > -----END PGP SIGNATURE----- > >
it worked. Here is the code: #include<gtk/gtk.h> #include<vte/vte.h> #include<stdio.h> void fork_done(VteTerminal *vte, gpointer udata) { printf("Process died!!\n"); } gboolean window_deleted( GtkWidget *w, GdkEvent *ev, gpointer data) { GtkWidget *vte = (GtkWidget*)data; char *text = "\n"; printf("Finish command\n"); vte_terminal_feed_child(VTE_TERMINAL(vte), text, strlen(text)); gtk_widget_hide_all(w); return TRUE; } int main(int argc, char* argv[]) { char *params[] = {"/bin/sh", "-c", "ls -l ~/;read",NULL}; char *env[] = {"PATH=/usr/bin:/bin:./usr/local/bin:/bin", NULL}; int child; gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); GtkWidget *table = gtk_table_new (1, 1, TRUE); GtkWidget *vte1 = vte_terminal_new (); gtk_signal_connect(GTK_OBJECT(vte1), "child-exited", G_CALLBACK(fork_done), NULL); gtk_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(window_deleted), vte1); gtk_table_attach_defaults (table, GTK_WIDGET(vte1), 0, 1, 0, 1); gtk_container_add (window, table); gtk_widget_show_all (window); child = vte_terminal_fork_command (VTE_TERMINAL(vte1), "sh", params, env, "~/", FALSE, FALSE, FALSE); printf("Child: %d\n", child); gtk_main (); return 0; } Thanks _______________________________________________ gnome-devel-list mailing list gnome-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gnome-devel-list