Just a note, the vcfutils.pl script threw an error for me. However, I was able to use this command to generate fasta consensus sequences:
samtools mpileup -uf ref.fa aln.bam | bcftools call -mv -Oz -o calls.vcf.gz
tabix calls.vcf.gz
cat ref.fa | bcftools consensus calls.vcf.gz > cns.fa
Source: https://github.com/samtools/bcftools/wiki/HOWTOs#consensus-calling
I am using samtools v1.3.1, htslib v1.3.1, and bcftools v1.3.1
try running step by step (make sure bam is sorted. Or try vcfutils that is attached to samtools /usr/share/samtools/vcfutils.pl)