Shell script loop not working

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script loop not working
# 1  
Old 11-22-2013
Shell script loop not working

I'm using this script to transcode videos in an Ubuntu 12.04 machine.
#! /bin/bash


#Video BitRate in kbps

echo "###################" >> $LOGS/transcode_dv_wrappers.log
echo "cmd $(LOGS/transcode_dv_wrappers.log)"

#Process Lock
if [ ! -e $LOCK_FILE ]; then
 touch $LOCK_FILE
shopt -s nullglob

for g in *.dv; do
Name=$(basename "$g" .dv)

        mv "$g" "$TMP";
        cd "$TMP";
        echo "FFMBC comenzó a convertir $g";
#Wrap a QuickTime Mov
        /usr/bin/ffmpeg -threads 0 -y -i "$g" -acodec copy -vcodec copy -f mov "$Name".mov;

#Elimina extensiones extra
        mv "$Name".mov "$MOVDESTDIR";
        mv "$g" .dv "$DONEFILESDIR";


rm -f $LOCK_FILE
echo "El script dv stream a DV wrappers todavia se esta ejecutando"

exit 0

Now I've tried to run this in a other computer, a Mint Olivia based one, the transcode process starts but it only works with the first file, and then

mv: cannot stat ‘.dv': No such file or directory
mv: cannot stat ‘A001119_NOSOTROS_EL_PUENTE_MICRO_02.dv': No such file or directory
FFMBC comenzó a convertir A001119_NOSOTROS_EL_PUENTE_MICRO_02.dv

I'm completely lost.
Thanks in advance!
# 2  
Old 11-22-2013
I guess it only works first because you are changing directory after first iteration:
cd "$TMP";

But I assume the files are actually present under $MOVDIR. So you have to go back to $MOVDIR
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

For loop in bourne shell is not working

I have a loop with cases I am working on Bourne shell for file in *.${Today}*.csv *.${Today}*.txt\ do case ${file} in sun_detail) do something ;; sum) do something ;; mod) do something ;; *) do something ;; (5 Replies)
Discussion started by: digioleg54
5 Replies

2. Shell Programming and Scripting

Cp not working in shell script but running perfectly from shell

Dear All, I have script. Dest="" IFS=' ' for translation in $(echo $MY_MAP) do t1=$(echo $translation | cut -d"=" -f1) t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1) if then Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2 break; ... (4 Replies)
Discussion started by: yadavricky
4 Replies

3. Ubuntu

Shell script not working accordingly

loop=y while do clear tput cup 5 15 echo -n "People Database" echo -n "====================================" tput cup 8 12 echo -n "L-Print Last Names" tput cup 9 12 echo -n "F-Print First NAmes" tput cup 10 12 echo -n "C-Print First Name, Last Name sorted by city" tput cup 11 12... (3 Replies)
Discussion started by: Akhilaprabhakar
3 Replies

4. Shell Programming and Scripting

[Solved] Simple script not working- for loop

Hi all, Please guide me writing this script Follwing is the file which I have created, which contains the files to be copied. cat system1-dr.txt /etc/passwd /etc/shadow /etc/group /etc/vfstab /etc/profile /etc/default/init /etc/shells /etc/dfs/dfstab /etc/dfs/sharetab... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

5. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

6. Shell Programming and Scripting

foreach loop working in terminal but not in the script

Hi, I am new here I have used the forums a long time to search for things they are very helpful. I have unfortunately used up all my resources (professors, grad students) and need some help. I have this very simple piece of code (using to isolate the problem) in a csh script: #!/bin/csh... (12 Replies)
Discussion started by: bflinchum
12 Replies

7. Shell Programming and Scripting

Shell Script not working using for loop and a funtion

Hi- Here is the shell script that for some reason is not returning results: #! /bin/ksh - avg() { AVG=0 typeset SUM=0 if then echo "You must have at least two numbers" else for NUM in "$*" do ... (2 Replies)
Discussion started by: koomba
2 Replies

8. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

9. UNIX for Dummies Questions & Answers

Anyone know?: How the 'for'-loop could stop working in interactive bash shell?!

It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected. That means or it is looping without exitting, or it is not loop even once. Here example of my try when it is not processing even one loop. You can see, I start new subshell and... (14 Replies)
Discussion started by: alex_5161
14 Replies

10. Shell Programming and Scripting

if loop not working in BASH shell

i have this code for a simple if loop: #!/bin/bash array="1 2 3 4 5" array2="5 6 7 8 9" if } -gt ${array} ]; then echo "${array2} is greater than ${array}!!" fi the error is ./script8: line 9: [: too many arguments ./script8: line 9: [: too many arguments ./script8: line 9: [:... (10 Replies)
Discussion started by: npatwardhan
10 Replies
Login or Register to Ask a Question