GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Aug 31, 2016 11:28 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How do I call a shell script from my Glade/GTK GUI?
PostPosted: Tue Jun 20, 2006 3:41 pm 

Joined: Tue Jun 20, 2006 3:39 pm
Posts: 1
I have some shell scrips that do HBA rescans and a bunch of other things. I built a GUI using Glade so that others would feel more comfortable running my scripts, but now I don't know how to call these scripts from my callbacks.c.

Any ideas?

I went through all the GTK commands and couldn't find anything.


 Post subject:
PostPosted: Sun Jul 02, 2006 10:24 pm 
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
It's not GTK that's going to help you, but standard C functions (assuming your'e working in C). In the callback for a button click or whatever you want to launch your command, you can use popen:

        FILE *fp;
        gint exit_status;
        gchar *command = "/this/is/the/script";

        /* execute command */
        fp = popen(command, "r");
   if (fp == NULL)
                g_print("Error running %s", command);
        exit_status = pclose (fp);
        g_print("Script exited with status %d", exit_status);

That's just off the top of my head so you may have to dink around. Do a google search for popen for more information.

Micah Carrick - Forum Administrator

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group