This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

neophyte scripter getting time to format correctly

Help for those learning Tcl or writing their own scripts.
Post Reply
M
MacGyver
Voice
Posts: 9
Joined: Mon Apr 26, 2004 3:12 am
Location: Dark side of the moon

neophyte scripter getting time to format correctly

Post by MacGyver »

Code: Select all

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: Select all

<+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
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

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.
Post Reply