Hi,
I would write a shell script to execute a series of command. However, if the cmd contains "-" in the array. It fails to do so.
I'd tried use ', " or \ but get the same result.
Quote:
#!/bin/bash
function checkConfig ()
{
for process in ${diskInfo[@]}
do
eval "${process}"
done
}
# Disk info details to be tar into tape
diskInfo=( 'df -k' "/sbin/fdisk -l" "cat /etc/fstab" )
checkConfig
|
Output:
Quote:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 51605464 6134364 42849696 13% /
/dev/sda1 101086 17977 77890 19% /boot
none 2072328 0 2072328 0% /dev/shm
/dev/sda5 807659692 144174644 622458256 19% /u01
./test.sh: line 31: -k: command not found
Usage: fdisk [-l] [-b SSZ] [-u] device
E.g.: fdisk /dev/hda (for the first IDE disk)
or: fdisk /dev/sdc (for the third SCSI disk)
or: fdisk /dev/eda (for the first PS/2 ESDI drive)
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)
...
./test.sh: line 31: -l: command not found
|