Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > Code & Utilities

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
37%
Installation Wizard into new VRC
39%
Manual into existing VRC
3%
Manual into new VRC
21%
Total votes: 38

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #16  
Old 19th September 2003, 20:33
jpvdgiessen's Avatar
jpvdgiessen jpvdgiessen is offline
Member
 
Join Date: Sep 2003
Location: Netherlands
Posts: 54
jpvdgiessen is on a distinguished road
Baan: triton2.1, triton3.1, baanIV - DB: bisam, tbase, informix, oracle, mySQL - OS: AIX, HP-UX, Linux (Suse+Redhat), W2K, NT
Instead of $ducmd = "du -ks"; you can use the following idea of getting the size of a directory.
I suppose no subdirectories are in it.

Code:
#!/usr/bin/perl
	$dir = $BSE_TMP ;
	opendir(DIR, "$dir");   # read all files
		my @Files = sort( grep -f, map "$dir/$_", grep !/^\./, readdir DIR);
	closedir(DIR);
	foreach $file (@Files) {

		$Size += -s $file ;   # read size of file and add to $Size
		}
	print "$file $Size\n" ;

For getting information about the disksize:

Code:
    use Filesys::DiskSpace;
    ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df $dir;

or with the following code (is more de unix like df command):
Code:
    use Filesys::DiskFree;
    $handle = new Filesys::DiskFree;
    $handle->df();
    print "The root device is ".$handle->device("/")."\n";
    print "It has ".$handle->avail("/")." bytes available\n";
    print "It has ".$handle->total("/")." bytes total\n";
    print "It has ".$handle->used("/")." bytes used\n";
__________________
Regards,

Jan Pieter
Reply With Quote
  #17  
Old 23rd April 2008, 11:59
afripack's Avatar
afripack afripack is offline
Junior Member
 
Join Date: Oct 2007
Location: Durban South Africa
Posts: 21
afripack is on a distinguished road
Baan: IVc - DB: SQL Server - OS: Win2K
Hi Learner, did you ever get a response for this or how did you overcome it? Am also on Win2K and don't know anything about Perl.

Mike

Last edited by mark_h : 23rd April 2008 at 17:43. Reason: little change
Reply With Quote
  #18  
Old 10th November 2008, 16:42
TimoJanssen TimoJanssen is offline
Junior Member
 
Join Date: Jun 2004
Location: Netherlands
Posts: 8
TimoJanssen is on a distinguished road
Baan: ERP LN 6.1 FP3 - DB: MS-SQL 2005 - OS: Windows 2003 Server
Simple batch file for Windows to delete tmp files

Schedule this simple batchfile to run for example every week.
Code:
set BSE=d:\baan
d:
cd %BSE%\TMP
for /f %%a in (%BSE%\TMP\cleanlist) do @del %%a
del %BSE%\TMP\cleanlist
for /f %%b in ('dir /a-d /b %BSE%\TMP\tmp*') do @echo %%b >> %BSE%\TMP\cleanlist
It simply dumps all tmp* filenames in 'cleanlist'. Ans in the second run (1 week later) it deletes all files from the 'cleanlist'.

Timo
Reply With Quote
  #19  
Old 11th November 2008, 08:44
afripack's Avatar
afripack afripack is offline
Junior Member
 
Join Date: Oct 2007
Location: Durban South Africa
Posts: 21
afripack is on a distinguished road
Baan: IVc - DB: SQL Server - OS: Win2K
Hi Timo, thanks for the reply... our developer came up with this script which is really great, we run it as a job every night.
Code:
|******************************************************************************
|* txcom9998  0  VRC B40C c4 afpt
|* Clear the tmp directory
|* afpk
|* 01-05-08 [16:02]
|******************************************************************************
|* Script Type: 4
|******************************************************************************
| This program will clear the $BSE\tmp directory of old files and files too large in order to maintain 
| the tmp directory size
| It will run based on a) age of file in days and b) size of files in Megabytes as input
| by the user
|                                                                       
|****************************** DECLARATION SECTION ***************************

declaration:
	extern 	domain	tcdate	date.inp
	extern	domain	tcmcs.long	days.del
	extern	domain	tcmcs.long	filsiz
	extern	domain	tcmcs.long  bytsiz
        long    fd, sfd
        long    rt
        string  home(80)
        string  fname(80)
	  string  dfname(80)
 	  string  dname(80)
        long    file.size
        long    change.time
        long    modified.time
        long    access.time
        long    check.time

	long 	ret
	long 	size, mode, inode, dev, uid, gid, nlink, ctime, atime
	long  modtime



before.program:
	date.inp = date.num()
	display("date.inp")

form.1:
init.form:
	get.screen.defaults()
 
|****************************** CHOICE      SECTION ***************************
field.days.del:
check.input:
	if  days.del < 7 then 
		message("You cannot set to delete for less that 7 days old",1)
		set.input.error("")
	else
		if   days.del < 30 then
			message("Warning - you are setting to delete before the recommended allowed days - 30",1)
		endif 
	endif

field.filsiz:
check.input:
	if   filsiz < 1 then
		message("Enter a size in Megabytes - recommended 50 or greater",1)
		set.input.error("")
	endif

choice.cont.process:
on.choice:
	  
        home = bse.tmp.dir$()
 	  bytsiz = filsiz * 1000000
        check.time = (date.num() - date.to.num(1970,1,1) - days.del) * (24 * 3600) 
        fd = dir.open(home)
        repeat
               fname = dir.entry(fd, TDIR+TFILE, rt, size, mode)
               if not isspace(fname) then
				if stat.info( home & "\" & fname,
							size,
							mode,
							inode,
							dev,
							uid,
							gid,
							nlink,
							ctime,
							modtime,
							atime ) = 0 then
					if ( S_ISDIR( mode ) ) then
						if modtime < check.time then
							dname = home & "\" & fname 
							clear.directory()
							rmdir(dname)
						endif
					else
						if modtime < check.time then
							file.rm(home & "\" & fname)
						endif
						if  size > bytsiz then 
							file.rm(home & "\" & fname)
						endif
					endif
                       endif
               endif
        until (isspace(fname))
        e = dir.close(fd)


functions:
function clear.directory()
{
        sfd = dir.open(dname)
        repeat
               dfname = dir.entry(sfd, TDIR+TFILE, rt, size, mode)
               if not isspace(dfname) then
                       if file.stat(  dname & "/" & dfname, 
                                      file.size, 
                                      change.time, 
                                      modified.time,
                                      access.time) = 0 then
                               if modified.time < check.time then
                                      file.rm(dname & "/" & dfname)
                               endif
                       endif
               endif
        until (isspace(dfname))
        e = dir.close(sfd)

}

Last edited by ~Vamsi : 12th November 2008 at 17:56. Reason: Syntax Highlighting Tags added
Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read files from a directory one by one vishbaan Tools Development 9 3rd December 2014 21:57
NEW: vbcode CODE extensions patvdv About Baanboard.com 3 13th March 2003 12:19


All times are GMT +2. The time now is 02:39.


©2001-2017 - Baanboard.com - Baanforums.com