Computing.Net > Forums > Unix > Can someone help wid KSH script err

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Can someone help wid KSH script err

Reply to Message Icon

Name: Kalyan_Unix
Date: January 31, 2008 at 07:21:06 Pacific
OS: Unix
CPU/Ram: Intel
Comment:

Hi All:

I am a newbie for ksh scripting.My code doesn't work. Can someone help?
I am trying to automate the process of file read from a directory. The files older than 3 days are supposed to be archived. If they are in the three day limit, then they can be processed as a comand lien to a C program.
Here is the script:

#!/usr/bin/ksh
checkduration=259200 # 3 days in seconds
cur_timestamp=`date +%s` #current time in seconds

cd /home/roab/toc/; # change dir
for i in /home/roab/toc/*; do
if [ -f $i ]; then # if the file is there
filename=${i#/home/roab/toc};# get file name
last_mod=$(stat -c "%Y" ${i#/home/roab/toc}); # get last mod time of file in seconds last_mod=$(stat -c "%Y" filename)
#above line gathers file modified time in seconds from epoch

if [ $last_mod ]
then
time_diff=`expr $cur_timestamp - $last_mod`; #cal time difference 3 days or more
if [ $time_diff -lt $checkduration ] # file modified three days or less back
then
mv ${i#/home/roab/toc} /home/roab/old_data; #if more then move to a new folder
else
/root/home/source/programs/abc.out filename; # if not call c program with filename as argument
cat filename>>log; #append this file name to log sheet
fi
fi
fi


the following are the errors:
stat: cannot stat `/22018-000181': No such file or directory
stat: cannot stat `/22018-000182': No such file or directory
stat: cannot stat `/22018-000183': No such file or directory
stat: cannot stat `/22018-000184': No such file or directory
stat: cannot stat `/22018-000185': No such file or directory
stat: cannot stat `/22018-000186': No such file or directory
stat: cannot stat `/22018-000187': No such file or directory


Please help.

rgds,
kalyan




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Sort keys provided from a... determines my default she...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Can someone help wid KSH script err

Need Help With KSH Script www.computing.net/answers/unix/need-help-with-ksh-script/6747.html

Urgent help with KSH script www.computing.net/answers/unix/urgent-help-with-ksh-script/8014.html

Need help on shell script www.computing.net/answers/unix/need-help-on-shell-script/6042.html