executing script shows some warnings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting executing script shows some warnings
# 1  
Old 10-20-2011
executing script shows some warnings

Hi,

Upon executing the below script .....

Code:
#!/bin/sh
while read DAYS INDIR OUTDIR
do
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done </home/Administrator/scripts/tarconfig.sh


I got the following error...
Quote:
find: invalid argument 'mv' to '-mtime'
and the files are transferred to out put folder from input folder also, that is script is working fine,but why it shows the error, please guide me ..!!Smilie
# 2  
Old 10-20-2011
We need to see the contents of tarconfig.sh to see what data you're feeding into find there. I think you're giving it something which is being interpreted as a -flag somewhere.
# 3  
Old 10-20-2011
Quote:
Originally Posted by Corona688
We need to see the contents of tarconfig.sh to see what data you're feeding into find there. I think you're giving it something which is being interpreted as a -flag somewhere.

Hi,

The content of the tarconfig.sh is below
Quote:
16 /home/Administrator/files /home/Administrator/output
# 4  
Old 10-20-2011
Have you tried:
Code:
find $INDIR -type f "!" -mtime $DAYS | xargs -t -I {} mv "{}" $OUTDIR

It uses an extra pipe, but it prints the command being execute!

---------- Post updated at 15:11 ---------- Previous update was at 14:59 ----------

I copied your script and no error to me!
Code:
# more teste.sh tarconfig.sh
::::::::::::::
teste.sh
::::::::::::::
#!/bin/sh
while read DAYS INDIR OUTDIR
do
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done < ./tarconfig.sh

::::::::::::::
tarconfig.sh
::::::::::::::
16 ./files ./output

You can try a more verbose one, try to put some "echo" inside the while:

Code:
# more teste.sh
#!/bin/sh
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done < ./tarconfig.sh

This User Gave Thanks to felipe.vinturin For This Post:
# 5  
Old 10-20-2011
Quote:
Originally Posted by felipe.vinturin
Have you tried:
Code:
find $INDIR -type f "!" -mtime $DAYS | xargs -t -I {} mv "{}" $OUTDIR

It uses an extra pipe, but it prints the command being execute!
Hi,

I have tried this also , the best thing that it shows on console also the files beig moved, but the same warnings...

Quote:
find: invalid argument 'mv' to '-mtime'

is still being shown at my cywgin console...Smilie
# 6  
Old 10-20-2011
Please, try this one:
Code:
#!/bin/sh -x
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find ${INDIR} -type f -mtime ${DAYS} -exec mv {} ${OUTDIR} \;
done < ./tarconfig.sh

You can see two differences in this one:
-----> "#!/bin/sh -x" in the first line (you can use it as "set -x"), more verbose
-----> All variables enclosed with: "${}"

I also tried in my cygwin and no error!

---------- Post updated at 15:29 ---------- Previous update was at 15:28 ----------

You will see something like:
Code:
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR

I hope it helps!
This User Gave Thanks to felipe.vinturin For This Post:
# 7  
Old 10-20-2011
Quote:
Originally Posted by felipe.vinturin
Please, try this one:
Code:
#!/bin/sh -x
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find ${INDIR} -type f -mtime ${DAYS} -exec mv {} ${OUTDIR} \;
done < ./tarconfig.sh

You can see two differences in this one:
-----> "#!/bin/sh -x" in the first line (you can use it as "set -x"), more verbose
-----> All variables enclosed with: "${}"

I also tried in my cygwin and no error!

---------- Post updated at 15:29 ---------- Previous update was at 15:28 ----------

You will see something like:
Code:
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR

I hope it helps!
so shall I try this latest one in my main script file the code below...

Code:
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

• Write a shell script that upon invocation shows the time and date and lists all the logged-in user

help me (1 Reply)
Discussion started by: sonu pandey
1 Replies

2. Shell Programming and Scripting

Infinite while loop script shows more than one process

Hi, I have a script which triggers an infinite loop. #!bin/bash trig=`ls /home/trig.tch |wc -l` function callj { some commands... } while do callj & done The number of process after doing a ps -ef |grep Mon.sh returns processes even after the script is killed by deleting the... (4 Replies)
Discussion started by: chetan.c
4 Replies

3. Shell Programming and Scripting

How to handle errors and warnings

Hi Guys, I am working on a shell script(main script) where in i have to call another script B and pass parameter to that script. I see that the shell script that is being called in the main script is throwing warnings/fatal errors. So i am just wondering how do i capture these and ask the script... (1 Reply)
Discussion started by: stunnerz_84
1 Replies

4. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

5. AIX

Warnings in AIX

Dear experts, please help in this regard, when i am trying to compile some files for 64 bit in AIX, iam getting this warning "/usr/include/alloca.h", line 34.9: 1540-1401 (I) An unknown "pragma __alloca" is specified. how to solve this warning , what is the significance of this please... (1 Reply)
Discussion started by: vin_pll
1 Replies

6. Solaris

Not getting warnings!!

I have tried to compile the code on solaris which is bash-3.00$ uname -a SunOS zen 5.7 Generic_106541-37 sun4u sparc SUNW,Ultra-80 bash-3.00$ CC -V CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0 when I compile just a simple program, int main() { long kk = 200; int jj = kk; return... (0 Replies)
Discussion started by: amit_27
0 Replies

7. Shell Programming and Scripting

Suppress awk warnings

Hello everyone, Sorry if this is a bit of an RTM thing, but I can't find any flags for suppressing warnings with awk and Googling (this site too) didn't yield much useful. Does anyone know how to suppress warnings? The warning I'm specifically trying to remove is one warning me that I'm... (1 Reply)
Discussion started by: kdelok
1 Replies

8. Shell Programming and Scripting

need to extract warnings and cautions

I need to extract all "text" from within <WARNING>text</WARNING> and "text" from within <CAUTION>text</CAUTION> tags in an SGML file. I need this separated or formatted in a file so that I can copy and paste the warnings and cautions into a table. Looking for ideas. Thanks. (4 Replies)
Discussion started by: ScotRite
4 Replies

9. AIX

Sysback Warnings

I am currently running backups using an entry in the crontab redirection the output to a file. From time to time I get a backup complete with Warnings but don't know what the warnings are and they don't appear in the file. Where can I view the warings? Is there a command to view the warnings? ... (2 Replies)
Discussion started by: daveisme
2 Replies
Login or Register to Ask a Question