GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I call a shell script from my Glade/GTK GUI?

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
OPTIMO



Joined: 20 Jun 2006
Posts: 1

PostPosted: Tue Jun 20, 2006 3:41 pm    Post subject: How do I call a shell script from my Glade/GTK GUI? Reply with quote

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.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 427
Location: Portland, OR USA

PostPosted: Sun Jul 02, 2006 10:24 pm    Post subject: Reply with quote

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:

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14

        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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP