|
发表于 2004-2-17 19:15:49
|
显示全部楼层
$ vi fdisk.exp
- #!/usr/bin/expect -f
- spawn fdisk /dev/hda
- expect -exact "Command (m for help): "
- send -- "p\r"
- expect -exact "Command (m for help): "
- send -- "q\r"
- expect eof
复制代码
$ chmod +x fdisk.exp
$ ./fdisk.exp ## 输出如下
- spawn fdisk /dev/hda
- The number of cylinders for this disk is set to 9729.
- There is nothing wrong with that, but this is larger than 1024,
- and could in certain setups cause problems with:
- 1) software that runs at boot time (e.g., old versions of LILO)
- 2) booting and partitioning software from other OSs
- (e.g., DOS FDISK, OS/2 FDISK)
- Command (m for help): p
- Disk /dev/hda: 80.0 GB, 80026361856 bytes
- 255 heads, 63 sectors/track, 9729 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/hda1 * 1 1275 10241406 83 Linux
- /dev/hda2 1276 1340 522112+ 82 Linux swap
- /dev/hda3 1341 9729 67384642+ 5 Extended
- /dev/hda5 1341 4987 29294496 83 Linux
- /dev/hda6 4988 6203 9767488+ 83 Linux
- /dev/hda7 6204 7419 9767488+ 83 Linux
- /dev/hda8 7420 8635 9767488+ 83 Linux
- /dev/hda9 8636 9729 8787523+ 83 Linux
- Command (m for help): q
复制代码 |
|