nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

I Back

This is a discussion on I Back within the Shell scripting forums, part of the Development/Scripting category; Very quite on these forums guys ive been away alot but ive been reading my books so now am ready ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 05-21-2006, 05:15 PM
Member
User
 
Join Date: Mar 2006
Posts: 35
Rep Power: 0
sparky
Default I Back

Very quite on these forums guys ive been away alot but ive been reading my books so now am ready to busy things up few questions.
I'll post them separately to keep it tidy
while i was away i was wondering what is the best way to turn my shell scripts into a web based interface where others could log in and use them.
Is this possible with shell scripts or would i have to use something else like perl or php.
I have been googling this for a while and all examples seem to be perl
(which i intent to learn but one thing at time i guess is best)
If it is possible could someone post an example or a link to some examples
Thanks guys
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-22-2006, 02:09 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Welcome back

Run shell script from web page: http://www.cyberciti.biz/faqs/2006/0...m-web-page.php
and http://www.cyberciti.biz/nixcraft/fo...opic.php?t=405
Sample php code:
Code:
<?php
$out=system("ls -l");
$da=system("date");
echo "$out 
 $da";
?>
Hope this helps
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 05-22-2006, 11:22 PM
tom tom is offline
Contributors
User
 
Join Date: Jun 2005
Location: London, UK
Posts: 213
Rep Power: 4
tom is on a distinguished road
Default

Which book you were reading?
Reply With Quote
  #4 (permalink)  
Old 05-28-2006, 03:28 PM
Member
User
 
Join Date: Mar 2006
Posts: 35
Rep Power: 0
sparky
Default

After reading upfor a while i decided to buy Classic shell scripting Classic shell scripting
But i found this book to be a bit to compicated for me even thou i have writtening a few simple scripts with your guys help
So i then ordered Beginning shell scriptingThis is a much better book for beginners much easier to understand.
when i have read and understood this book i am sure the first one will make more sense.
I am at the moment look for a good simple book on sed and awk then may be perl.
Thanks for your reply rockdalinux But did not help to much can t seem to find any examples that would help turn my scripts into a little web panel you could log in to and manage any examples i find seems to be in perl with php.
my script basically add user starts and stop css servers etc
This what i see in ssh but i like to add this to a web page interface
What do you wish to do ? anwser 1 to 10

1. Start css server
2. Change rcon pass word
3. View server start details
4. Add user details
5 View user detail
6. Server.cfg tick conf
7. Restart Servers
8. Teamspeak options
9. Search for records
10. Delete records

Answer (or 'q' to quit)
Any examples would be great
Or may be i am barking up the wrong tree and i would need to program with something else to make this work.
Reply With Quote
  #5 (permalink)  
Old 05-28-2006, 06:14 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Hmm

If you want to turn it into web panel then I suggest you go for perl. To be frank you can use shell scripts running as cgi. But perl (or php) is good for this kind of work. Now let us talk about logic:

When you will login, it will display menu as you suggested:

Let us say you have 10 shell scripts for 10 jobs as 1.cgi, 2.cgi … 10.cgi

So when user select first option you need to run 1.cgi and output back its status to browser. It is that simple.

Now it may be simple task for me but not for newbie like you. So here is some idea / code to kick start your work.

wpan.php (put in /var/www/html/my/ or your web root dir):
Code:
<?php
// path to cgi-bin script
$cgiurl="http://localhost:81/cgi-bin";

function head(){
 echo "<html><head><title>my Web Panel</title></head><body>";
}

function foot(){
  echo "</body></html>";
}

function menu(){
global $cgiurl;
echo "<a href=$cgiurl/1.cgi>1. Start css server</a>
";
echo "<a href=$cgiurl/2.cgi>2. Change rcon pass word</a>
";
echo "<a href=$cgiurl/3.cgi>3. View server start details</a>
";
echo "<a href=$cgiurl/4.cgi>4. Add user details</a>
";
echo "<a href=$cgiurl/5.cgi>5 View user detail</a>
";
echo "<a href=$cgiurl/6.cgi>6. Server.cfg tick conf</a>
";
echo "<a href=$cgiurl/7.cgi>7. Restart Servers</a>
";
echo "<a href=$cgiurl/8.cgi>8. Teamspeak options</a>
";
echo "<a href=$cgiurl/9.cgi>9. Search for records</a>
";
echo "<a href=$cgiurl/10.cgi>10. Delete records</a>
";
}

head();
menu();
foot();
?>
Make sure you point out $cgiurl to correct cgi-bin path and domain name.

Now, put 1.cgi in /usr/lib/cgi-bin or directory where cgi-bin are permitted:
1.cgi
Code:
#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Start css server</title></head><body>"
echo "Put your Actual shell code to start css server :)
"
echo "<a href=javascript:history.back();>Go back to web panel</a>"
echo "</body></html>"
1.cgi is nothing but a shell script. You need to put your actual logic to restart the server or delete record and so on…

This is a sample script, use same logic to create all other scripts. Make sure you put all scripts in a password protected directories so that only you can access them.

Now open browser and run wpan.php, if everything is correct (code and location) you should able to run actual shell script from your own panel.

No matter how many books you read you will never find a real life example (either you implement it or ask someone who has actually implemented it) That is why I wrote this entire example for you.

If you need more help, just start specific new thread and some will assist you and Good luck with your project.
Reply With Quote
  #6 (permalink)  
Old 05-28-2006, 08:36 PM
Member
User
 
Join Date: Mar 2006
Posts: 35
Rep Power: 0
sparky
Default

Thanks that will give me a good bases to start on
exactly what i neeeded
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
I am BaCk B!n@ry The Hangout 4 01-11-2007 05:31 PM


All times are GMT +5.5. The time now is 06:40 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36