Jump to content

Recommended Posts

Posted

Ive made a few basic 'frontend' (if you can call them that) bash scripts for some programs that require many -flags where it will prompt for each setting, and then run the program based on the user input.

 

Similar to the oldschool batch files, which any tom dick and pony could make, there wasnt really a GUI equivelent until AutoIT (as far as I know)

 

My question is, is there anything a complete newbie like me can use to make a GUI frontend, that will take the options inserted into fields in a GUI, and then launch an external program populating the various flags with what has been entered into the various boxes in the GUI?

 

Hope this makes sense?/

 

Cheers

 

RB

Posted
Hmm, I don't know if ncurses can do what you're after, it's worth looking at. But I think you'll probably be looking at a more complex language like python and PyGtk, which I think it probably the 'easiest' combination.
Posted
is there anything a complete newbie like me can use to make a GUI frontend

 

A web page. It's the exact processing model you're after - stick a form on the screen, the user fills it in and hits "submit", the data is sent to a web server and calls the command-line application via system() or whatever. All you need is a small web server to listen out on a port (doesn't have to be port 80). Python has a web server module that lets you write a small web server in about 3 lines of code.

 

--

David Hicks

Posted
A web page. It's the exact processing model you're after - stick a form on the screen, the user fills it in and hits "submit", the data is sent to a web server and calls the command-line application via system() or whatever. All you need is a small web server to listen out on a port (doesn't have to be port 80). Python has a web server module that lets you write a small web server in about 3 lines of code.

 

--

David Hicks

 

I was imagining something that would be distributable, rather than having to have them run a web server seems a bit complicated. Thanks though.

 

building little C Sharp applications with Mono
and
gambas
Im afraid I am going to have to look up as I have no clue.

 

Python again I have not dabbled with. But will give it a look.

Posted

if your using gnome you could allways use "zenity" your script can bring up a series of simple 1 line input boxes.

 

Zenity examples

 

it basically works by putting "var=$(zenity --entry --text "Does this work")", the users input is now in $var

  • Thanks 1
Posted
I was imagining something that would be distributable, rather than having to have them run a web server seems a bit complicated.

 

No, Python lets you write a web server in a few lines of code, it's the simples thing ever!

 

--

David Hicks

  • Thanks 1
Posted

Is the machine that will be running the bash script a webserver? if it is write a simple PHP page with a form on it, then take the POST data and do this:

 

system("sh /path/to/script/script.sh -flag \"{$_POST['value']}\")

 

not sure if using \" will work, or if {$var['var']} will, but you get the idea

Posted

Xdialog is a nice simple frontend for bash scripts.

 

Xdialog

 

That is the website, gives you lots of examples so you can copy and paste (just highlight what one you want and the script appears below), its what we use to use before we went web-based and is really simple.

 

Jo

  • Thanks 1
  • 1 year later...
Posted

Please take a look to my BASH library: EasyBashGUI

sites.google.com/site/easybashgui

 

Goal is making very easy bash "GUI" script creation...

:-)

Posted

With my library:

it's so easy... (easybashgui)

 

You can use indifferently -with same script- dialog, Xdialog, kdialog or zenity. If you want, you can force use one of them, or you can make Easybashgui choose for you.

In the latter case, it chooses "dialog" if X is not running, or Xdialog, kdialog and zenity are not present in your system, otherwise it chooses "Xdialog", "kdialog" or "zenity" depending on wich D.E. are running script into ( e.g.: KDE, GNOME, or others... ).

 

Important point is: all is done with same script, and shell scripter has not to worry about everything .

 

Bye

:)

Posted (edited)

Well, webman...

 

First of all, my method, even if you want only "dialog mode" boxes, already has an advantage: it simplifies a lot scripter work.

 

An example.

This would be command line handling directly "dialog" (from its man page), about a "menu" box:

>dialog --menu

...

Special options:

[--create-rc "Ifile"]

Common options:

[--aspect ] [--backtitle ] [--beep] [--beep-after]

[--begin ] [--cancel-label ] [--clear] [--colors]

[--cr-wrap] [--default-item ] [--defaultno] [--exit-label ]

[--extra-button] [--extra-label ] [--help-button]

[--help-label ] [--help-status] [--ignore] [--input-fd ]

[--insecure] [--item-help] [--keep-window] [--max-input ]

[--no-cancel] [--no-collapse] [--no-kill] [--no-label ]

[--no-shadow] [--ok-label ] [--output-fd ] [--print-maxsize]

[--print-size] [--print-version] [--separate-output]

[--separate-widget ] [--shadow] [--single-quoted] [--size-err]

[--sleep ] [--stderr] [--stdout] [--tab-correct] [--tab-len ]

[--timeout ] [--title ] [--trim] [--visit-items]

[--version] [--yes-label ]

As you see, features are a lot, you have a great control on almost everything, but it's a little bit confusing, at least at beginning.

 

EasyBashGUI, instead, since its goal is simplify scripter's work, would be like so:

>export supermode="dialog" && source easybashgui

>menu ...

...it's enough.

 

If you want deepest control, maybe EasyBashGUI is not for you; if you want simplicity, maybe EasyBashGUI is useful for your needs.

 

Moreover, you should carefully consider that your script could one day used in a graphical environment.

It's not an improbable event. You wrote a program to your geek friend, but now he's asking to you to give a nicer gui; or former intended target user is now no more comfortable with terminal programs, now being an happy KDE user; and so forth...

In that way, using my library,

>adjust "Please, set Volume" "0" "35" "100"

will work exactly the same, with dialog and, in KDE, with kdialog, without any modification.

This is, IMO, a priceless potential feature, you should consider it.

 

:)

Edited by vaisarger
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...