what RC="$?" exactly do?
and will the data of RC drop ?
example:
i have 10 miror checker in the scriot,
i have to define RC for all of them or change it to RC3 RC4 ?
i want to know the dead time of this variable only
there are several reason when an error occurred during wget:
sometimes timeout error happened
sometimes file doesnt exist,
sometimes file exist But the server does not have permission to download
in these cases, is this methid work fine? coz all of these situation has their own error number,
RC=$? sets the variable RC, which is a synonym for Return Code, to exactly this, others use 'RET', 'ret', 'return_code' or something alike. $? contains the return code of the previously executed command.
SriniShoo:
run wget
set RC to $?
Compare RC with 0 (success)
If anything else but 0, call wget for mirror2
sea:
run wget
return code is anything but 0, call wget for mirror2
So, yes, either solution will jump in upon any fail.
Of course, you could to handle the error code, in the like of (i didnt check return codes for wget):
if [ $answer == 1 ]; then
wget $MIRROR
RC="$?"
case "$RC" in
0) echo "All done well" ;;
1) echo "Regular fail"
wget $MIRROR2 ;;
*) echo "Error: $RC" ;;
esac
fi