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.
Old posts that have not been replied to for several years.
-
u
up^to^you
Post
by up^to^you »
hi....
i need help about to make tcl that automatically set timer to die if it cant find a file in the shell
thx
-
ppslim
- Revered One
- Posts: 3914
- Joined: Sun Sep 23, 2001 8:00 pm
- Location: Liverpool, England
Post
by ppslim »
somthing like
Code: Select all
set file_chk {
{/etc/hosts}
{/home/users/eggdrop/files/die.if.not.exists}
}
bind time - "*" check_file
proc check_file {min hour day month year} {
global file_chk
foreach a $file_chk {
set msg "Checking for file $a :"
if {![file exists $a]} {
die "$msg Failed"
} else {
putlog "$msg Passed"
}
}
}
This will check once a min for each file int he list. You can add code to reduce it down to once every 5 mins, 10 mins or whatever you want.
Place a # infront of the word "putlog" to stop it from displaying passed everytime.
-
u
up^to^you
Post
by up^to^you »
if i want to use check a directory in my shell, shall i change it to:
set dir "/home/blah/"
if {![dir exists $a]} {
??
-
ppslim
- Revered One
- Posts: 3914
- Joined: Sun Sep 23, 2001 8:00 pm
- Location: Liverpool, England
Post
by ppslim »
No need, "file exists" will check directories too.
Simply place the directory in the list, and it will dot he work.
% file exists /etc/passwd
1
% file exists /etc/passwd.bak
0
% file exists /etc/
1
% file exists /etf/
0