Quote:
Originally Posted by hruday
U did no corrections. please correct the script.
|
In my signature is a link to my blog entry on BASH programming where I show how to do some debug steps for your scripts, My Bash Blog.
One technique is to echo variable values, or echo progress, as you are doing. Another technique is to add the line:
near the top of your script, but after the #!/bin/sh line. This will enable verbose debugging and you'll see the progress of the script as well as more details. Give the blog a look for other recommendations.
Note that only you know the full requirements and what you're trying to achieve, and therefore you should evaluate and test with the whole variety of expected conditions that you can conceive of.
For me I would take the mtime qualifiers out at first and ensure that it performs the basic find and exec command, and then add back in the mtime qualifiers. Because a reason why it might not see any files is because there are none to see.
I'm assuming by the way that you do have a:
line in your code?
Further, there's also a link in my signature discussing how to put your code within [code][/code] markers to have it appear properly in a post.
I ran a modified variation of your script on my testcode directory and it worked fine:
Code:
#!/bin/sh
path1="/home/myuser/testcode"
path2="/home/myuser/testcode"
echo "listing files"
find $path1/*.c -exec ls {} \;
sleep 3
find $path2/*.c -exec ls {} \;
echo "files listed"
exit
The result was:
Code:
listing files
/home/myuser/testcode/a.c
/home/myuser/testcode/array.c
/home/myuser/testcode/bright.c
/home/myuser/testcode/decode.c
-- 3 second pause was here --
/home/myuser/testcode/a.c
/home/myuser/testcode/array.c
/home/myuser/testcode/bright.c
/home/myuser/testcode/decode.c
files listed
I also found that adding in the "-type f" and '-lht" terms cause no problems.
procfs's suggestion to add a debug statement between the first find and the second find is a good idea by the way, in fact you should add a statement before the sleep 3 and just after it to know that it's reached that second find command.
Are you saying that you never see the final "files listed" comment?