How can i use a command that has a menu


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i use a command that has a menu
# 1  
Old 08-17-2009
How can i use a command that has a menu

I am a complete newbie to linux/unix so please be kind.

I am trying to write a script to be used on a Buffalo terastation NAS. The terastation has a command "mfdisk" that is used for partition manipulation. I need to be able to use mfdisk in my script but the problem is it has a command menu and im not sure how to access that in a script.

I need to be able to access the sub menu calls and use them to manipulate the partition. I checked for a man page but could not find anything besides the help menu below.

Below are both the direct calls to mfdisk and then the menu calls after using the -c switch.

Thanks for any help you can offer on this matter.

Code:
>>mfdisk -h
Partition table manipulator for BUFFALO INC. LinkStation series. ver 2.0, Nov  5
 2005
Usage: mfdisk DISK     Create partition tables for HD-LAN ver 1.xx
       mfdisk -f DISK  Create partition tables for HD-LAN ver 2.xx
       mfdisk -h DISK  Create partition tables for HD-HLAN
       mfdisk -g [1:2:3:5:10:20:50] DISK  Create partition tables
       mfdisk -a DISK  Create partition table for HD-HLAN's USB Disk
       mfdisk -c DISK  Create partition table(s) with menu
       mfdisk -p DISK  Check partition table(s)
       mfdisk -e DISK  Deleate all partition tables
       mfdisk -d [1:2:3:4:5:6:7] DISK  Create partition tables for LinkStation/T
eraStation
Here DISK is something like /dev/hda or /dev/sda
>>
>>
>>mfdisk -c /dev/sda
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
Command (m for help):

# 2  
Old 08-18-2009
This may work:
Code:
mfdisk -h << EEOOFF
m
EEOOFF

Replace the m with the series of answers (one letter per line), experiment with care!

If the above heretext idea does not work you could look at expect(1) to do the answering?
# 3  
Old 08-18-2009
You might be better off using fdisk
Code:
$ fdisk -h                        
Usage: fdisk                                  
[ -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]
[ -b masterboot ]                                            
[ -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect ]
[ -F fdisk_file ] [ -h ] [ -o offset ] [ -P fill_patt ] [ -s size ]
[ -S geom_file ] [ [ -v ] -W { creat_fdisk_file | - } ]            
[ -w | r | d | n | I | B | E | g | G | R | t | T ] rdevice         
    Partition options:                                             
        -A id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect  
                Create a partition with specific attributes:       
                id      = system id number (fdisk.h) for the partition type
                act     = active partition flag (0 is off and 128 is on)   
                bhead   = beginning head for start of partition            
                bsect   = beginning sector for start of partition          
                bcyl    = beginning cylinder for start of partition        
                ehead   = ending head for end of partition                 
                esect   = ending sector for end of partition               
                ecyl    = ending cylinder for end of partition             
                rsect   = sector number from start of disk for             
                          start of partition                               
                numsect = partition size in sectors                        
        -b master_boot                                                     
                Use master_boot as the master boot file.                   
        -B      Create one Solaris partition that uses the entire disk.    
        -E      Create one EFI partition that uses the entire disk.        
        -D id:act:bhead:bsect:bcyl:ehead:esect:ecyl:rsect:numsect          
                Delete a partition. See attribute definitions for -A.      
        -F fdisk_file                                                      
                Use fdisk_file to initialize on-line fdisk table.          
        -I      Forego device checks. Generate a file image of what would go
                on a disk using the geometry specified with the -S option.  
        -n      Do not run in interactive mode.                             
        -R      Open the disk device as read-only.                          
        -t      Check and adjust VTOC to be consistent with fdisk table.    
                VTOC slices exceeding the partition size will be truncated. 
        -T      Check and adjust VTOC to be consistent with fdisk table.    
                VTOC slices exceeding the partition size will be removed.   
        -W fdisk_file                                                       
                Write on-disk table to fdisk_file.                          
        -W -    Write on-disk table to standard output.                     
        -v      Display virtual geometry. Must be used with the -W option.  
    Diagnostic options:                                                     
        -d      Activate debug information about progress.                  
        -g      Write label geometry to standard output:                    
                PCYL            number of physical cylinders                
                NCYL            number of usable cylinders
                ACYL            number of alternate cylinders
                BCYL            cylinder offset
                NHEADS          number of heads
                NSECTORS        number of sectors per track
                SECTSIZ         size of a sector in bytes
        -G      Write physical geometry to standard output (see -g).
        -h      Issue this verbose help message.
        -o offset
                Block offset from start of disk (default 0). Ignored if
                -P # specified.
        -P fill_patt
                Fill disk with pattern fill_patt. fill_patt can be decimal or
                hexadecimal and is used as number for constant long word
                pattern. If fill_patt is "#" then pattern of block #
                for each block. Pattern is put in each block as long words
                and fills each block (see -o and -s).
        -r      Read from a disk to stdout (see -o and -s).
        -s size Number of blocks on which to perform operation (see -o).
        -S geom_file
                Use geom_file to set the label geometry (see -g).
        -w      Write to a disk from stdin (see -o and -s).

Alternatively, write the partition table from a disk image (safer option, but you'd have to have the same size partitions each time)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies

2. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

3. Red Hat

Not able to see the terminal icon in the applications menu to launch the command prompt in Centos

After installing centos iam not able to see the terminal icon in the applications menu to launch the command prompt in Centos. However iam able to see the Open Terminal menu, when i right click and it is not working. let me know what are the things i need to check.:b: (1 Reply)
Discussion started by: Kesavan
1 Replies

4. Homework & Coursework Questions

About menu using dd command utility

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: Please help about these script... i dont have a problem in option 1. But when it comes to options 2 and options 3... (2 Replies)
Discussion started by: amneytia1
2 Replies

5. UNIX for Dummies Questions & Answers

What is a menu or command line option driven script?

i'm confused what this means. i was asked to design a menu or command line option driven script that reads out of a DB and displays info such as read_data.pl -u <user> -e <event> which would print commands run by <user>with the <event> in the db. any suggestions? i've been using... (2 Replies)
Discussion started by: kpddong
2 Replies

6. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

7. Shell Programming and Scripting

Error using select menu command

Hi All, I am trying to use the select command & the menu. below mention is my script #!/bin/bash 2 3 PS3="Is today your birthday? " #PS3 system variable 4 5 echo "\n" 6 7 8 select menu_selection in YES NO QUIT 9 do 10 11 ... (1 Reply)
Discussion started by: milindb
1 Replies

8. Shell Programming and Scripting

Menu list in Unix csh - command not found

Hello, im taking a class of Unix and i dont really know much about it, im trying to create a list of menu a user would select from and im very lost. Basically it will have 5 options, the user will chose from: 1. list files in the pwd 2. display date and time 3. is the file file or directory 4.... (5 Replies)
Discussion started by: morava
5 Replies

9. Shell Programming and Scripting

Select command to build menu

Hello everyone. I am using the select command to build a menu, here is my question: Is it possible to generate a menu which contains several sections and have a separator between the sections without having a selection number generated in front of the separator? This is a sample of what I would... (1 Reply)
Discussion started by: gio001
1 Replies

10. Shell Programming and Scripting

put a icon/command in menu bar

Hey everyone :)my problem is i want to add a command and icon to the menu panel, normally in gnome you would just right click, add to panel etc. What i want to do is, for example , put say firefox plus a icon in the menu bar by using a bash script, what would be the command, to do this. (5 Replies)
Discussion started by: dave123
5 Replies
Login or Register to Ask a Question