Bash - Need to use exit but then call another function?

I'm writing a little script to use the webcam on the laptop and then email across the photo to me. The ffmpeg usage has to have a exit code for it to work so with this exit the mail function will not get called. What am I doing wrong?

#!/bin/bash

MAIL_ADDR=user@example.com
ts=`date +%s`
list=$(ls | tail -n 1)

function mcheese(){
mkdir /tmp/cheese
cd /tmp/cheese
echo -e "Cheese " | mutt -s "$TS Cheese" $MAIL_ADDR -a $list
}

function cheese(){
ffmpeg -f video4linux2 -s vga -i /dev/video0 -vframes 3 /tmp/cheese/vid-$ts.%01d.jpg 
exit 0
}

cheese
mcheese

Answers


You setup list in one directory, then change directory and use it. This is unlikely to work.

Use bash -x to work out where your script is actually failing.


Need Your Help

AWS EC2 Elastic IPs bandwidth usage and charges

amazon-web-services amazon-ec2 amazon bandwidth

I have a little questions regarding Elastic IPs and its charge. Some blogs says that Elastic IP will charge you by the bandwidth you use

jQuery Fullcalendar - in week view, mark all days with color, if event allDay is true

jquery fullcalendar

In week agenda view, if any event is allDay:true, mark this event days (from start date till end date) with different background (like current day), vertically.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.