| View previous topic :: View next topic |
| Author |
Message |
MacGyver Voice
Joined: 26 Apr 2004 Posts: 9 Location: Dark side of the moon
|
Posted: Thu Jul 05, 2007 2:52 pm Post subject: neophyte scripter getting time to format correctly |
|
|
| Code: | bind pub - !tf findfile2
proc findfile2 {nick uhost hand chan text} {
set file1a "/home/BabyEcm/test/test1.txt"
set file1b "/home/BabyEcm/test/test2.txt"
set file2a "/home/BabyEcm/test/test3.txt"
set file2b "/home/BabyEcm/test/test4.txt"
# Open file for read access (note we're not catching errors, you might
# want to use catch {} if the file might not exist.
puthelp "PRIVMSG $chan :working on a tcl routine to detect files"
if {[file exists $file1a] == 1} {
set ynmsg "$file1a does exist"
set cfdateunix [file mtime $file1a]
set creationdate [strftime $cfdateunix %r]
} else {
set ynmsg "$file1a does NOT exist"
}
# Here we read in all of the data.
puthelp "PRIVMSG $chan :$ynmsg, $creationdate"
} |
output on channel
| Code: | <+BabyEcm> working on a tcl routine to detect files
<+BabyEcm> /home/BabyEcm/test/test1.txt does exist, 1183648942 |
just writing scripts to learn and how do I get the file modication date to display in english. _________________ Mac |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Thu Jul 05, 2007 5:40 pm Post subject: |
|
|
for starters, you should set creationdate to 0 by default or you will start getting errors with files that don't exist..
You can use strftime to change the output time, have a look at tcl-commands.doc. |
|
| Back to top |
|
 |
|