I have return a script which is needed to return a value if it is successfully completed.
my code is :
Code: Select all
#!/bin/bash
echo "enter the source path for file1 with file extension"
source1=/root/Desktop/source/b14313.pdf.gz
echo "enter file1 name with extension"
file1=b14313.pdf.gz
echo "enter the source path for file2 with file extension"
source2=/root/Desktop/source/Oracle_10g_Installation.pdf.gz
echo "enter file2 name with extension"
file2=Oracle_10g_Installation.pdf.gz
echo "Target location : "
target=/root/Desktop/target/asd/
abcd()
{
echo "$file1 started copying...."
cp $source1 $target
val=`expr $val + 1`
echo "$file1 is copied to target location successfully"
echo "$file2 started copying...."
cp $source2 $target
val=`expr $val + 1`
cd $target
echo "$file1 started uncompressing.."
gunzip $file1
val=`expr $val + 1`
echo "$file1 uncompressed successfully"
echo "$file2 started uncompressing.."
gunzip $file2
val=`expr $val + 1`
echo "Files unzipped"
ret1=$?
echo "return1 value is $ret1"
}
abcd
ret=$?
echo "return value is $ret"
It need to return a value 0 ..
If everything is executed properly.. All the things are executing properly the value is returning zero but the problem is that when am trying to give wrong input also it is returning zero .. please help...
can you please put it into a function ..
please help... !