Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 23rd, 2004, 10:57 AM   #1
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,650
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
here is my menu script i wrote awhile back. i know its pretty boring but im bored and thought i should post something in here finally

menu
#bin/sh
cd
clear
menu.awk
while :
do
    read INPUT_STRING
    case $INPUT_STRING in
    1)
        echo "Enter the name or ip of computer you want to connect to."
        read ssh_string
        echo "Enter your user name for this machine."
        read user_string
        ssh -l $user_string $ssh_string
        clear
        menu.awk
        ;;
    2)
        clear
        mc
        clear
        menu.awk
        ;;

    3)
        clear
        echo "Option 3 is Unused"; echo
        menu.awk
        ;;
    4)
        echo "Enter File to change permissions of."
        read file_perm
        echo "Enter permissions you want to use, using the number system."
        read perm
        chmod $perm $file_perm
        clear
        echo "File permissions have been changed."; echo
        menu.awk
        ;;
    5)
        echo "Enter Directory to change permisions of."
        read dir_perm
        echo "Enter permissions you want to use, using the number system."
        read perm2
        chmod -R $perm2 $dir_perm
        clear
        echo "Directory permissions have been changed."; echo
        menu.awk
        ;;
    6)
        clear
        ls -la | less
        echo
        menu.awk
        ;;
    7)
        echo "Enter the Directory you want to move to."
        read dir
        cd $dir
        clear
        menu.awk
        ;;
    8)
        clear
        echo "Enter File you want to edit"
        read file
        vim $file
        clear
        menu.awk
        ;;
    9)
        clear
        echo "Option 9 is Unused"; echo
        menu.awk
        ;;
    10)
        clear
        echo "Option 10 is Unused"; echo
        menu.awk
        ;;
    clear)
        clear
        menu.awk
        ;;
    //)
        echo "Exiting!"
        break
        ;;
    *)
        echo "Sorry, I don't understand"
        ;;
esac
done

menu.awk
awk 'BEGIN { menu="************** MENU ****************\n"
    menu=menu "* 1) SSH To Remote Computer    *\n"
    menu=menu "* 2) Midnight Commander      *\n"
    menu=menu "*   (Command line file manager) *\n"
    menu=menu "* 3)                *\n"
    menu=menu "* 4) Change File Permissions   *\n"
    menu=menu "* 5) Change Dir Permissions    *\n"
    menu=menu "* 6) List Files in Directory   *\n"
    menu=menu "* 7) Change Directory       *\n"
    menu=menu "* 8) Edit File in Direcotry    *\n"
    menu=menu "* 9)                *\n"
    menu=menu "* 10)               *\n"
    menu=menu "*                 *\n"
    menu=menu "* clear) Clear Screen       *\n"
    menu=menu "* //) Quit to Prompt        *\n"
    menu=menu "************************************\n"
    menu=menu "\n"
    menu=menu "Enter Your Selection: "
    print menu }'

if you put both of these files in your /usr/bin/ dir you can just run the thing by typing menu anywhere you are
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Nov 23rd, 2004, 11:05 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Now there's an idea... if anyone wants my JavaScript/PHP/XML menu generator, let me know. Nice code, K.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 23rd, 2004, 11:05 AM   #3
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,650
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
create a thread and post it

This menu system could be used when you dont want to give a user full access to the computer and only want to give them a few commands. you could set it up for when ever they ssh into the machine the menu automaticly runs and then with they exit the menu it could log out of the computer for them and then the only access they get is what you give them on the menu
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Nov 23rd, 2004, 4:44 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Sounds like a really good idea to me.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 24th, 2004, 11:19 AM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Looks pretty good man, I'm going to put it on my Fedora Core 3, Gentoo, Ubuntu, and Solaris 10 boxes to test it out for ya... maybe add a bit to it too.

Feelings are hurt cuz you don't have a "Compile C program" option... lol
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 24th, 2004, 11:39 AM   #6
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,650
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
i couldnt think of anymore options to put into it but thats a good one. if you modify it let me know i would like to see what other options would be good to add to it

just figured this out if you add this to the users .profile file then it will run automaticly when they login via ssh

ok i have added a compile c++ and c options and even a run a.out cause thats what the code compiles to on my computer when i dont get a specific name

menu
#bin/sh
cd
clear
/home/big_k/menu/menu.awk
while :
do
    read INPUT_STRING
    case $INPUT_STRING in
    1)
        echo "Enter the name or ip of computer you want to connect to."
        read ssh_string
        echo "Enter your user name for this machine."
        read user_string
        ssh -l $user_string $ssh_string
        clear
        /home/big_k/menu/menu.awk
        ;;
    2)
        clear
        mc
        clear
        /home/big_k/menu/menu.awk
        ;;

    3)
        clear
        echo "Option 3 is Unused"; echo
        /home/big_k/menu/menu.awk
        ;;
    4)
        echo "Enter File to change permissions of."
        read file_perm
        echo "Enter permissions you want to use, using the number system."
        read perm
        chmod $perm $file_perm
        clear
        echo "File permissions have been changed."; echo
        /home/big_k/menu/menu.awk
        ;;
    5)
        echo "Enter Directory to change permisions of."
        read dir_perm
        echo "Enter permissions you want to use, using the number system."
        read perm2
        chmod -R $perm2 $dir_perm
        clear
        echo "Directory permissions have been changed."; echo
        /home/big_k/menu/menu.awk
        ;;
    6)
        clear
        ls -la | less
        echo
        /home/big_k/menu/menu.awk
        ;;
    7)
        echo "Enter the Directory you want to move to."
        read dir
        cd $dir
        clear
        /home/big_k/menu/menu.awk
        ;;
    8)
        clear
        echo "Enter File you want to edit"
        read file
        vim $file
        clear
        /home/big_k/menu/menu.awk
        ;;
    9)
        clear
        echo "Enter C++ Program to compile."
        read file
        g++ $file
        /home/big_k/menu/menu.awk
        ;;
    10)
        clear
        echo "Enter C Program to compile."
        read file
        gcc $file
        /home/big_k/menu/menu.awk
        ;;
    11)
        clear
        a.out
        /home/big_k/menu/menu.awk
        ;;
    clear)
        clear
        /home/big_k/menu/menu.awk
        ;;
    //)
        echo "Exiting!"
        break
        ;;
    *)
        echo "Sorry, I don't understand"
        ;;
esac
done

menu.awk
awk 'BEGIN { menu="************** MENU ****************\n"
    menu=menu "* 1) SSH To Remote Computer    *\n"
    menu=menu "* 2) Midnight Commander      *\n"
    menu=menu "*   (Command line file manager) *\n"
    menu=menu "* 3) Still Not Used        *\n"
    menu=menu "* 4) Change File Permissions   *\n"
    menu=menu "* 5) Change Dir Permissions    *\n"
    menu=menu "* 6) List Files in Directory   *\n"
    menu=menu "* 7) Change Directory       *\n"
    menu=menu "* 8) Edit File in Direcotry    *\n"
    menu=menu "* 9) Compile C++ Program     *\n"
    menu=menu "* 10) Compile C Program      *\n"
    menu=menu "* 11) Run a.out          *\n"
    menu=menu "*                 *\n"
    menu=menu "* clear) Clear Screen       *\n"
    menu=menu "* //) Quit to Prompt        *\n"
    menu=menu "************************************\n"
    menu=menu "\n"
    menu=menu "Enter Your Selection: "
    print menu }'
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Nov 24th, 2004, 6:20 PM   #7
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Just added a few changes to the compile options to where you can put in a name for the binary that was created.

Changed the run a.out option to Run Program... so you can run any program you want (that you have perms to run).

Also, removed the cd command from the top of menu.sh to make the menu work with the current directory or directory specified instead of defaulting to home directory.

These are minor, trivial changes... that I needed for my "instance" of Big K's menu script.

Good work man!


menu.sh
-----------
    9)
        clear
        echo "Enter C++ Program to compile."
        read file
    echo "Enter program name: "
    read pname
        g++ $file -o $pname
        menu.awk
       ;;
    10)
        clear
        echo "Enter C Program to compile."
        read file
    echo "Enter program name: "
    read pname
        gcc $file -o $pname
        menu.awk
       ;;
    11)
        clear
    echo "Enter program to run:"
    read pname
        $pname 
        menu.awk
       ;;


menu.awk
-------------

 menu=menu "* 11) Run Program         *\n"
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC