Shell scripts error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripts error
# 1  
Old 11-02-2012
Shell scripts error

Dear all

I have shell script where files have been organized into directory, i pass the directory name and it shold pick all the files within the directory and move to differnet path.

When i run the scripts it doesn't move and come out with error and i am not able to understand it

the error is


mv: Insufficient arguments (1)
Usage: mv [-f] [-i] f1 f2
mv [-f] [-i] f1 ... fn d1
mv [-f] [-i] d1 d2

scripts is
Code:
 
#this shell will loadd all the LOG files data in oracle
# The below line will copy the logs to respective forlder so tha ETL will read the LOGS from there.
  NEWDIR=RIO_16-Oct-2012
        cd /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/
 if [ -d $NEWDIR ]; then
         echo "Directory exis $NEWDIR"
 else
          mkdir /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 fi
 cd /ersdg3/ERS/ERS_INPUT_LOGS/RIO/rio_archive/$NEWDIR/
 #touch -t `date +%Y%m%d0000` dummy
 #find . -newer dummy -type f  |
 while read fname
 do
     mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 done
 cd /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 for i in *.LOG
 do
 wc -l $i | awk '{ print $1"|"$2"|RIO" }'
 done>RIO_AUDIT_REC.TXT

Any help will be greate help. there is no iussue of privileges
# 2  
Old 11-02-2012
Your while loop does not have any input, hence fname variable is not assigned, supply an input like below:-

Code:
while read fname
do
     mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
done < input_file

# 3  
Old 11-02-2012
Code:
while read fname
 do
     mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 done<RIO_AUDIT_REC.TXT

 for i in *.LOG
 do
 wc -l $i | awk '{ print $1"|"$2"|RIO" }'
 done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting error in shell scripts

Hi, I have a shell script confug-msys.sh which callls config-common.sh. When run from command prompt,these work fine but give the below error when i try to run from code-blocks line 7: --without-contrib: command not found ...Also I am unable to understand what the second script does...... (4 Replies)
Discussion started by: binnyshah
4 Replies

2. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

3. Shell Programming and Scripting

Advanced error handling in shell scripts

Hi all I've got a question regarding error handling in shell scripts. My background is mainly object oriented programming languages, but for a year or so I've been doing more and more (bash) shell scripting (which I quite enjoy by the way). To handle errors in my scripts I... (3 Replies)
Discussion started by: script_man
3 Replies

4. Shell Programming and Scripting

Error Checking in Shell scripts.

What i need to do is when the database connection is not successful , the script should move to next list i.e skip the current. But when i do this - if ; then break; fi The script break but it goes to the condition - if ; then for LIST in $LISTS do for TABLE in $TABLES do... (2 Replies)
Discussion started by: dinjo_jo
2 Replies

5. HP-UX

Shell Scripts

I have a text file . Format of text file. djss:xd:78:isdev:"test server" this type of row. (approx 30). I want to display like that 1. djjs@msxd testserver 2. xjfd@msxd devserver 3. 4 select any one from above choice : 1... (5 Replies)
Discussion started by: rastogideepak
5 Replies

6. Shell Programming and Scripting

Need Help With Shell scripts

Hello, I'm very very fresh with unix, and I would like to get familiar with it. I want to know what is Shell scripting and how other programming languages connects with it. And is there any way to learn the shell scripting, with some book and some simulator to practice on. Thanks ahead. (2 Replies)
Discussion started by: holler1
2 Replies

7. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

8. Shell Programming and Scripting

shell scripts help

Hi, I am not experienced in shell scripts, I hope someone can give some hint for the following problem I have html file like this <html> <body> Some stuff More stuff <pre> A B </pre> Still more stuff And more <pre> C D </pre> Additional stuff </body> (2 Replies)
Discussion started by: ccp
2 Replies

9. UNIX for Advanced & Expert Users

Error Handling in Korn Shell scripts

Hi, I am using few ISQL statements to update and delete from a few tables in sybase, now i want to roll back the transaction when any of the statements fail.How i can i capture these errors in the shell scripts.Please advise. Thanks, Gopi (4 Replies)
Discussion started by: bhgopi
4 Replies

10. Shell Programming and Scripting

shell scripts

Hi! I have added a line into /etc/profile which looks like- date > $HOME/.lastloggedon This puts a file lastloggedon into everyones directory who has logged in recently. The trouble I am having is getting the information back out. I was hoping there was a command using find which brought... (1 Reply)
Discussion started by: karenshaw
1 Replies
Login or Register to Ask a Question