LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Front-end for shell scripts (https://www.linuxquestions.org/questions/programming-9/front-end-for-shell-scripts-576644/)

bingo 08-12-2007 10:17 PM

Front-end for shell scripts
 
I have a collection of shell scripts that I would like to build front-ends for. The requirements are very simple... some input fields and a button to execute "script(input1, input2, etc.)". Where should I start for this? I apologize if this is trivial, this isn't my specialty :-) Thanks!

slakmagik 08-12-2007 10:21 PM

Just grab gtkdialog or xdialog (even gxmessage or xmessage for the simplest stuff). You could reinvent a more specific or straightforward wheel in the language of your choice, but they should suffice for most things.

-- Something in your phrasing made me think 'GUI' but, if you mean a console frontend then dialog/cdialog is okay.

munna_dude 08-12-2007 11:24 PM

Quote:

Originally Posted by bingo (Post 2856848)
I have a collection of shell scripts that I would like to build front-ends for. The requirements are very simple... some input fields and a button to execute "script(input1, input2, etc.)". Where should I start for this? I apologize if this is trivial, this isn't my specialty :-) Thanks!

hi
here some useful example..
there is two buttons...
i used here gtk..

Code:

#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib.h>

GtkWidget *status_bar;

static void push_item( GtkWidget *widget,
                      gpointer  data )
{
  static int count = 1;
  gchar *buff;

  buff = g_strdup_printf ("Item %d", count++);
  gtk_statusbar_push (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data), buff);
  g_free (buff);
}

static void pop_item( GtkWidget *widget,
                      gpointer  data )
{
  gtk_statusbar_pop (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data));
}

int main( int  argc,
          char *argv[] )
{

    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *button;

    gint context_id;

    gtk_init (&argc, &argv);

    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);
    gtk_window_set_title (GTK_WINDOW (window), "GTK Example");
    g_signal_connect (G_OBJECT (window), "delete_event",
                      G_CALLBACK (exit), NULL);
 
    vbox = gtk_vbox_new (FALSE, 1);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);
         
    status_bar = gtk_statusbar_new ();     
    gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0);
    gtk_widget_show (status_bar);

    context_id = gtk_statusbar_get_context_id(
                          GTK_STATUSBAR (status_bar), "Statusbar example");

    button = gtk_button_new_with_label ("push item");
    g_signal_connect (G_OBJECT (button), "clicked",
                      G_CALLBACK (push_item), GINT_TO_POINTER (context_id));
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 2);
    gtk_widget_show (button);             

    button = gtk_button_new_with_label ("pop last item");
    g_signal_connect (G_OBJECT (button), "clicked",
                      G_CALLBACK (pop_item), GINT_TO_POINTER (context_id));
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 2);
    gtk_widget_show (button);

    /* always display the window as the last step so it all splashes on
    * the screen at once. */
    gtk_widget_show (window);

    gtk_main ();

    return 0;
}

will be usefull

cheers..
munna

bigearsbilly 08-13-2007 03:17 AM

you may find tcl/tk ideal for this.
it's dead easy to use,

(assuming you have it installed)
type this into an xterm and you will get a button
that does an ls
Code:

wish
button .b -text hello -command "/bin/ls"
pack .b


gnashley 08-13-2007 07:01 AM

Xdialog is the most complete implementation of what you want. It uses the GTK libs so it is pretty universally compatible. I use it hundreds of ways, but I've also found and use other tools like greq, gxmessage or gtk-shell for special needs.

slakmagik 08-13-2007 04:12 PM

Quote:

Originally Posted by gnashley (Post 2857237)
Xdialog is the most complete implementation of what you want. It uses the GTK libs so it is pretty universally compatible.

It probably would do what he wants, but I'm not sure I'd agree that it's the most complete. It has a lot of widgets but they are pretty limited - there's no '--4inputsbox ', for instance - just 1-3. Gtkdialog let's you essentially define most any interface out of a few widget atoms, so to speak, and you can define stuff with glade if you have to. And while gtk is pretty universal, debian-devel is having a fight now about removing it - gtk2 is also pretty universal and not about to be removed from anything. Xdialog has an essentially unsupported compile option to use gtk2 but is basically a gtk1 app, gtkdialog is gtk2.

But both are cool and will cover most needs. :)

pixellany 08-13-2007 05:51 PM

If I understand the question correctly, Zenity is a pretty simple way of makin a GUI interface to a script.

slakmagik 08-13-2007 07:36 PM

zenity is gnome-specific, though - it may well work without the whole enchilada, but it needs a lot of gnome libs and junk like gconf. Bingo didn't say, so that may be okay but, odds are, with him running Slackware especially, gnome deps would be a negative.

bingo 08-13-2007 08:19 PM

Wow, thanks for all of the feedback! After the replies, I started reading more, and found that Slackware includes "dialog". It's been very simple to code, and I'm used to the interface from the Slackware utilities. There are probably limitations to what this tool can do, but it's working for me, and it doesn't need X, so it's very fast. Thanks again! ...Steve

pixellany 08-13-2007 08:48 PM

Quote:

Originally Posted by digiot (Post 2857939)
zenity is gnome-specific, though - it may well work without the whole enchilada, but it needs a lot of gnome libs and junk like gconf. Bingo didn't say, so that may be okay but, odds are, with him running Slackware especially, gnome deps would be a negative.

I've installed Zenity on two different KDE boxes--no issues whatever: It's in the repositories, grabs a few libraries, and all is good. I don't get upset about Gnome libs when using GIMP either. Is that an issue for Slackware users???

slakmagik 08-13-2007 10:24 PM

Gimp is just a gtk2 app - it doesn't actually require any gnome stuff. Just gtk2 and a truckload of multimedia libs. And since it's part of Slackware, all that's taken care of. :)

Actually, I stand somewhat corrected, though - looking at zenity on a Debian box, it would just install libart, a couple of libgnomecanvas libs, and scrollkeeper and libscrollkeeper. And I can't imagine scrollkeeper is an actual functional requisite. So it's not as much as I was thinking, but still some junk as opposed to the various other solutions. I was thinking it wanted gconf and a bunch of other garbage.


All times are GMT -5. The time now is 05:09 AM.