Hi Pareshan,
Try this approach.
This will generate a sql script from df command's output and then insert the data.
# --------------------------------------
server=`hostname` # Get server name in a shell veriable
sqlfile=$server.sql
df | awk -v serv=$server '
{print "insert into table1 values (~" serv "~,~" $1 "~,~" $6 "~," $2 "," $3 "," $4 "," $5 " );" }
' |
sed -e "s/~/'/g" -e 's/%//' > $sqlfile
# In above command awk will generate insert statement from df's output
# Then first
sed will replace all ~ with single quote
# next
sed will take out the percentage sigh from the insert
# Now insert the data
sqlplus -s /nolog <<EOSQL
connect user/pass@sid
whenever sqlerror exit 99 -- If there is error, this sqlplus will exit with non-zero status
@$sqlfile
commit;
exit
EOSQL
if [[ $? -ne 0 ]]
then
echo "Error while running file $sqlfile .....Run ... panic .... investigate"
fi
# ------------------------------------------------
I do not have a Unix session at hand, so I haven't run this script and tested, but this will work. I have done this before.
Enjoy...