Log in

View Full Version : New to scripting


lpn1160
10th April 2006, 06:51
I just started learning how to write shell scripts. The script runs a video capture thru the iso making and maybe I'll add burning to disk, if all goes well. as is, so far the script runs perfect.I need a little assistance/advice/Criticism. What I want to to do is when the script is complete delete all the files generated during the process, but only if all goes well with no errors. And I think there must be a way to be able to use any directory I'm in without changing the path manually in the script. I've read the man pages, on line guides etc but i don't understand (yet) all the little details. It's still in the rough
Here's my script:

#!/bin/bash
#cap 2 disk


streamer -n ntsc -b 24 -t 1:50:00 -s 480x480 -r 29.970 -R 48000 -o stream.avi -f mjpeg -j 90 -F stereo

mplayer *.avi -hardframedrop -vc dummy -vo null -ao pcm:file=audio.wav

echo "audio complete"
echo "start video stream copy"

mencoder *.avi -ovc copy -nosound -o video.avi

echo "encoding audio"

toolame audio.wav audio.mp2

echo "encoding video"


mencoder video.avi -o movie.m2v -sws 9 -ovc lavc -of rawvideo -mpegopts format=dvd -vf pullup,softskip,crop=448:464:8:8,scale=656:448,expand=704:480,harddup -lavcopts vcodec=mpeg2video:vrc_minrate=3000:vbitrate=3500:vrc_maxrate=7200:vmax_b_frames=1::vrc_buf_size=1835:trell:mbd=2:keyint=15:aspect=4/3 -nosound -ofps 24000/1001

echo "encoding video complete"

pulldown movie.m2v

mplex -f 8 -o newmovie.mpg pulldown.m2v audio.mp2

dvdauthor -c 00:00,03:00,06:00,09:00,12:00,15:00,18:00,21:00,24:00,27:00,30:00,33:00,36:00,39:00,42:00,45:00,48:00,51:00,54:00,57:00,60:00,1:03:00,1:06:00,1:09:00,1:12:00,1:15:00,1:18:00,1:21:00,1:24:00,1:27:00,1:30:00,1:33:00,1:36:00,1:39:00,1:42:00,1:48:00,1:51:00,1:54:00,1:57:00 -v 704x480 -o newdvd newmovie.mpg

dvdauthor -o newdvd -T


mkisofs -dvd-video -udf -V MY_VOLNAME -o newiso /mnt/D2P2/captures/newdvd

rm stream.avi
rm video.avi


#growisofs -Z /dev/hdc=/mnt/D2P2/captures
exit

Thank you all for any help,advice or whatever!!

ak
11th April 2006, 20:57
>What I want to to do is when the script is complete delete all the files generated during the process, but only if all goes well with no errors.

I believe, you can do like this
<command> && <do this if succeded> || <do that if failed>
or
<command>

if [ $? == 0 ]; then
echo yup
else
echo nope
fi
But before anything I would put your script in [code] here. helps readability and stuff :)