When I was using Bash Shell script to extract the available free space in the hard driver, there are several things that are worth to be noticed.
1. The importance to declare variables.
There is a segment fault when I was trying to invoke the C program from the script if the arguments that are forwarded to the C program is not declared at the beginning of the script. Next step should be to make clear what is the meaning of the parameters when the declaration was made. Those are called "variable attributes" (Burth, 73)
--------------------------------------------------------------------------------------------------
Just found that the arguments can only be declared to be read-only......
If I did not use the declaration, there will be a segment fault. However, today I confirm that if I lost a argument of shell script such as the path of the experiment it will also lead to a segment fault!
--------------------------------------------------------------------------------------------------
I just found the main problem within this issue. The structure has problem:
df | while read content
do
echo ${content}
temp=${content}
done
echo ${content}
echo ${temp}
The situation is the same with the following snippet of code:
df | read content
echo ${content}
It can not read anything after "df".