-1

I have written few shell scripts which can do specific tasks .

But my mangaer wants that there should be some web interface where , he can run those scripts and function using web .

Now i don't know how can i link bash with web .

I know PHP.

Also one thing more if i use python can i make web interface , or will it easir than programming in bash

closed as not constructive by Brent Pabst, splattne Sep 6 '12 at 11:27

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

4

If your manager insists there are some solutions like webmin or zentyal to manage GNU/linux servers from a web interface.

You can easily add your own scripts to those web interfaces. The advantage of using tested products over your own reinvent-the-wheel web service is that those web services are developed with security in mind.

However as a sysadmin I encourage you to admin your servers using just a shell (bash with screen for example) through ssh.

  • cpanel is also doing the same thing . Can i make small GUI in Bash that can do the stuff . can i see the same gui in putty client – Mirage Apr 30 '11 at 15:10
  • 1
    No, you cant have a single GUI that can be displayed in a terminal and in a web browser. – sciurus May 1 '11 at 4:38
3

I would highly NOT recommend to write a software in PHP, that has access to /bin or other relevant system parts and serve it via apache. Because: PHP is not strict, reliable and secure enough to realize programs as Webmin with.

But I wonder at all, why a manager would want to do administrative tasks on a server? Are those really administrative tasks? Or is it something, you could write in PHP from scratch? I mean, If he just wants to shrink an image, you don't need a bash script for that.

I wrote a remote installer in python once, that was only accessible in the companies intranet and executed a few scripts via an SSH connection, using certificates. It worked, but was really not a good solution. But I would recommend a way like this one, to have a relatively secure way to hack this together.

1

Webmin allows you to use commands via a remote interface.

http://www.webmin.com/

  • but i want to create my own small interface like click here to backup , click here to restore etc – Mirage Apr 30 '11 at 12:50
  • But why? Something is already made to do just what you want. – Cody Harlow Apr 30 '11 at 12:55
1

In case you don't prefer your manager to work on Webmin, and would like to have a simple user interface where your manager can work directly,

YES, you can link PHP and BASH using exec:

  • Create your GUI directory (ex: /var/www/html/MyManagerGUI/).

    # mkdir /var/www/html/MyManagerGUI/

  • Put your Bash scripts in one directory (ex: /var/www/MyManagerGUI/Scripts/), and give them execution permesion.

    # chmod +x /var/www/MyManagerGUI/Scripts/*

  • Create index.php file in /var/www/MyManagerGUI/

  • In your index.php file, call the Bash scripts from PHP by:

    <?php exec("cd Scripts/;./MyBash arg1 arg2" , $output); ?>

where $output is array contains all the results from your Bash, MyBash is your bash name, and arg1 arg2 are optional arguments

  • Change MyManagerGUI/ owner to Apahce

    # chown -R apache:apache /var/www/MyManagerGUI/

  • To secure your GUI, you can add .htaccess file in /var/www/MyManagerGUI/, like adding username and password or force https access.

Not the answer you're looking for? Browse other questions tagged or ask your own question.