Need a simple shell script made

Need a simple shell script made

Post by Matthias Wark » Mon, 02 Nov 1998 04:00:00




Quote:

> Ok guys,

> I have a small shell scripts that i have to write in UNIX. I have the logic
> down of the program, but I don't have the specifics of how to write it. Can
> someone help me out here? Here is the logic of the program:

Well, I have fixed it as well as I could, but I don't know how to
check time stamps. So, this is your pseudocode for the bash shell:

#!/bin/bash
# Resets variables
DateStampOfFile1=0
DateStampOfFile2=0

# Does an infinite loop. It compares the date of the file now with the
date of
# the file 20 minutes ago. If they are the same, copy a file over
while true
do DateStampOfFile1={Check to see the time and date stamp of\
the file/usr/local/blah}
   if [ $DateStampOfFile2 = $DateStampOfFile1 ]
   then cp /tmp/newblah /usr/local/blah
   fi   # Yeah, it's if-then-fi, it's really weird.
   DatestampOfFile2={Check to see the time and date stamp of the file\
/usr/local/blah}
   sleep $(( 20 * 60 ))  # Yes, I know it's 1200. This makes it
clearer.
done

mawa
--

My site's been cracked but it'll go up on another server soon. My Geek
Code is no longer in my .signature.  It's available on e-mail request.
/\/\/\\/\//\ (mawa) <-- this is why ASCII art in signatures is no good

 
 
 

Need a simple shell script made

Post by era eriksso » Wed, 04 Nov 1998 04:00:00



posted to comp.os.linux.misc,comp.unix.shell:
 > Well, I have fixed it as well as I could, but I don't know how to
 > check time stamps. So, this is your pseudocode for the bash shell:

man stat, or just do something like
datestamp=`ls -l "$file" | awk '{print $6, $7, $8}'`

Followups to comp.unix.shell.

/* era */

--
Bot Bait: It shouldn't even matter whether  (`')  Just  (`')  http://www.iki
I am a resident of the State of Washington   \/ Married! \/   .fi/~era/

 
 
 

Need a simple shell script made

Post by brian hile » Sat, 14 Nov 1998 04:00:00



> ...

When asking for free code to be written, one should at least specify
the shell, version, and why not the OS too....

In ksh, to test relative time-stamps of files:

[[ file1 -nt file2 ]]   # is file1 newer than file2?
[[ file1 -ot file2 ]]   # is file1 older than file2?

-Brian