Automate the menu options using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automate the menu options using shell script
# 1  
Old 05-06-2014
Hammer & Screwdriver Automate the menu options using shell script

I have a menu option which will look as follows
Select a menu option
1.change password
2.login as root user
3.show system version
4.quit
Select> 1
please enter the new password: unix
reenter the new password: unix
press any key to enter
(then displays again the menu options to enter the value)
Select a menu option
1.change password
2.login as root user
3.show system version
4.quit
Select>4
#

Question: the above the shell script in the linux
Now i want to automate the above script using shell scripting and create the report for the same

Can any body help me on this
what i tried is
1.Create a shell script
2.all the menu option values as inputs in the test file
3. generated outputs in the output file
4.Now i need to validate the values
for ex:1 changed the password successfully.............
5.I also need to generate the report for the same.

Please help me on this.

Thanks
Shiva
# 2  
Old 05-06-2014
If this is calling the supplied passwd command, then it will be difficult. The thing is that passwd will empty/ignore the input buffer you may supply and this is to stop people trying to subvert or bypass it.

There are some brute-force methods, but they increase the risk to compromising you accounts and losing access so you can't undo it.

My guess is that you want to automate setting your password across multiple servers which each have a simple menu system on them. Not a good plan. If you want to tie machines together in such a way, consider using one of:-
  • SSH keys
  • LDAP
  • NIS


Can you confirm what you really want to do/bypass?



Robin
# 3  
Old 05-06-2014
Quote:
Originally Posted by rbatte1
If this is calling the supplied passwd command, then it will be difficult. The thing is that passwd will empty/ignore the input buffer you may supply and this is to stop people trying to subvert or bypass it.

There are some brute-force methods, but they increase the risk to compromising you accounts and losing access so you can't undo it.

My guess is that you want to automate setting your password across multiple servers which each have a simple menu system on them. Not a good plan. If you want to tie machines together in such a way, consider using one of:-
  • SSH keys
  • LDAP
  • NIS


Can you confirm what you really want to do/bypass?



Robin
Hi Robin,

Actually the code of the menu items and corresponding calls to each option already done by some developers
may task is to test the options are working correctly or not.
i am giving one more example for
when i enter 3, the system version will be displayed by running a command "sudo /opt/systeminfo/version.sh"
output displayed for the input:
System Information:
------------------------
Version:1.0.0.1
Build number:12

Now using the automated script for this option
1.start the menu
2.Enter the value 3
3.Validate whether the Version and build number are similar to what exit in version
4.Display the report
Now i can be able to do 1 and 2 steps but how to do the step3 and step4...
# 4  
Old 05-06-2014
So a totally different thing to what you asked for in the first place? Count me out from assistance.
# 5  
Old 05-06-2014
Quote:
Originally Posted by rbatte1
So a totally different thing to what you asked for in the first place? Count me out from assistance.
Thanks Robin,

See i gave explanation for option1 in my main post
For understanding provided explanation for option3..

My intention is to automate the options present in the Menu and validate the outputs using shell scripting.

The code i wrote for my automation script
Code:
#!/bin/bash
/bin/bash -c  "su shelladmin  <  /tmp/testfile > /tmp/outputfile"

shelladmin is where the menu options are present.
This will take the input options in the testfile and prints everything in the outputfile
testfile has
1
unix
unix

4

EOF
Thanks
Shivakumar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to include menu based options in Shell script?

Hi Friends, I have a menu based tool which requires input/option to proceed further. How to make a shell script ? eg: menu looks like Get_data.sh to continue (y/n) : Here I need to key in "y" to proceed. I want to prepare a script which should consider option y. (5 Replies)
Discussion started by: suresh3566
5 Replies

2. Shell Programming and Scripting

How to automate user menu selections?

Hello all, I am sort of new to Shell programming and to this forum. I want to create a script that auto selects menu options. lets say I have a menu. MAIN MENU 1.) opt1 2.)opt2 3.)opt3 I want the script to automatically select option 1. (6 Replies)
Discussion started by: gerry8a
6 Replies

3. Shell Programming and Scripting

How to automate user selection options in shell script?

Hi There, I am trying to write a script which has to pick the prompted options by itself(i mean option to choose will be passed) here is real scenario i am trying to do. i have an executable(diagnos) which gets called in shell script, when the executable (diagnos) runs i get following as... (8 Replies)
Discussion started by: sairam_9191
8 Replies

4. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 Replies

5. Windows & DOS: Issues & Discussions

Windows Advanced Options Menu

I dual boot between Windows XP and Linux Mint. I am trying to get the Windows Advanced Options Menu to show up. Normally you would press f8 to make this happen when your computer is booting. With a dual boot it makes it way more complicated. If you press f8 when your computer first starts it does... (3 Replies)
Discussion started by: cokedude
3 Replies

6. Homework & Coursework Questions

Menu Driven Shell Script which accepts1 to 5 options

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) Write a Menu Driven Shell Script which accepts1 to 5 options and performs the following actions for... (1 Reply)
Discussion started by: vaghya
1 Replies

7. Shell Programming and Scripting

Automate shell script

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (3 Replies)
Discussion started by: sam786
3 Replies

8. UNIX for Advanced & Expert Users

Shell Script to Automate

I would like to automate script where i do not have to manually insert the username and password I wrote two different scripts but not able to achieve the results: here's to scripts i wrote #!/bin/bash cd /var/tmp /home/server/steve/pca --askauth -idx /opt/app/bin/expect <<EOF expect... (1 Reply)
Discussion started by: sam786
1 Replies

9. Shell Programming and Scripting

menu.lst, boot options?

Hi all, I would like to have some details on menu.lst!! the reason is ,if i am trying to add my own boot option where do i need to add it? is it in menu.lst only or elsewere(am referring to unix os) because i tried adding a unique boot option and it was not reflected when the system booted?... (8 Replies)
Discussion started by: wrapster
8 Replies

10. UNIX for Dummies Questions & Answers

Help needed with menu options

I'm programming a menu for an intro to unix class and am hung up on 2 required options. One has to exit from unix. The other has to get a command prompt by using one of the menu choices, then return to the menu via CTRL-D. below is my code #!/bin/ksh #Jimmy's happy menu mesg y msg="ON"... (2 Replies)
Discussion started by: sanitywonko
2 Replies
Login or Register to Ask a Question