Page 1 of 1 1
Topic Options
#209645 - 2014-11-14 05:16 AM Disk Space Query
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Hi

1. I have the script that I have specified per MB is "$MB = 1048576". See detail of my script at the bottom of this post.

Following are the results:
Drive C has 130GB of free space, it output as 130.159145355225
Drive D has 728GB of free space, it output as 728.70979309082
Drive E has 3.6TB of free space, it ouput as -1958.04564285278

What should be the correct value that I should input in $MB?

2.I have specified that if the disk space is less than 140GB, to show the text in RED. But this did not happen.

$x = WriteLine( 3 , +" <TD HEIGHT=30><B><FONT SIZE=3><FONT COLOR="+"Black"+">SMT-IT</FONT></FONT SIZE></B></TD>")
IF $PC01C < "140.0"
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"RED"+">"+$PC01CC+"<FONT COLOR="+"GREEN"+">"+$PC01CCC+"</FONT></FONT></FONT SIZE></TD>")
ELSE
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"#0000ff"+">"+$PC01CC+"<FONT COLOR="+"GREEN"+">"+$PC01CCC+"</FONT></FONT></FONT SIZE></TD>")
ENDIF


Following is my script:

$SMTITC = GetDiskSpace ("\\PC01\C$")
$SMTITD = GetDiskSpace ("\\PC01\D$")
$SMTITE = GetDiskSpace ("\\PC01\E$")

$MB = 1048576

$PC01CCC = " - 200 GB"
$PC01DDD = " - 730 GB"
$PC01EEE = " - 3.63 TB"

$PC01CC = cdbl($PC01C) / cdbl($MB)
$PC01CC
$PC01DD = cdbl($PC01D) / cdbl($MB)
$PC01DD
$PC01EE = cdbl($PC01E) / cdbl($MB)
$PC01EE

;SHELL "%COMSPEC% /C ECHO Y| DEL SVRDISKSPACE.HTML"

IF Open( 3 , "C:\SVRDISKSPACE.HTML" , 5 ) = 0

$x = WriteLine( 3 , +"<P><B><U><FONT SIZE=3><FONT COLOR="+"#0000ff"+">"+"Report of disk space for the following on " + "$DAY"+"/"+ "$MONTHNO" +"/"+ "@YEAR" +" ("+@DAY+")"+"</FONT></FONT SIZE></U></B></P>")

$x = WriteLine( 3 , +" <TABLE BORDER=1 WIDTH=60%>")
$x = WriteLine( 3 , +" <COLGROUP>")
$x = WriteLine( 3 , +" <COL ALIGN="+"centre"+">")
$x = WriteLine( 3 , +" <COL ALIGN="+"centre"+"VALIGN="+"middle"+">")
$x = WriteLine( 3 , +" </COLGROUP>")
$x = WriteLine( 3 , +" <COLGROUP SPAN=3 ALIGN="+"centre"+ "VALIGN="+"middle"+">")
$x = WriteLine( 3 , +" </COLGROUP>")

$x = WriteLine( 3 , +" <TR>")
$x = WriteLine( 3 , +" <TD HEIGHT=30><B><FONT SIZE=2><FONT COLOR="+"Black"+">DRIVE</FONT></FONT SIZE></B></TD>")
$x = WriteLine( 3 , +" <TH><B><FONT SIZE=3><FONT COLOR="+"Black"+">C</FONT></FONT SIZE></B></TH>")
$x = WriteLine( 3 , +" <TH><B><FONT SIZE=3><FONT COLOR="+"Black"+">D</FONT></FONT SIZE></B></TH>")
$x = WriteLine( 3 , +" <TH><B><FONT SIZE=3><FONT COLOR="+"Black"+">E</FONT></FONT SIZE></B></TH>")
$x = WriteLine( 3 , +" </TR>")
$x = WriteLine( 3 , +" <TR>")

$x = WriteLine( 3 , +" <TD HEIGHT=30><B><FONT SIZE=3><FONT COLOR="+"Black"+">SMT-IT</FONT></FONT SIZE></B></TD>")
IF $PC01C < "140.0"
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"RED"+">"+$PC01CC+"<FONT COLOR="+"GREEN"+">"+$PC01CCC+"</FONT></FONT></FONT SIZE></TD>")
ELSE
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"#0000ff"+">"+$PC01CC+"<FONT COLOR="+"GREEN"+">"+$PC01CCC+"</FONT></FONT></FONT SIZE></TD>")
ENDIF
IF $PC01D < "2.0"
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"RED"+">"+$PC01DD+"<FONT COLOR="+"GREEN"+">"+$PC01DDD+"</FONT></FONT></FONT SIZE></TD>")
ELSE
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"#0000ff"+">"+$PC01DD+"<FONT COLOR="+"GREEN"+">"+$PC01DDD+"</FONT></FONT></FONT SIZE></TD>")
ENDIF
IF $PC01E < "2.0"
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"RED"+">"+$PC01EE+"<FONT COLOR="+"GREEN"+">"+$PC01EEE+"</FONT></FONT></FONT SIZE></TD>")
$x = WriteLine( 3 , +" </TR>")
ELSE
$x = WriteLine( 3 , +" <TD><FONT SIZE=3><FONT COLOR="+"#0000ff"+">"+$PC01EE+"<FONT COLOR="+"GREEN"+">"+$PC01EEE+"</FONT></FONT></FONT SIZE></TD>")
$x = WriteLine( 3 , +" </TR>")
ENDIF

$x = WriteLine( 3 , +" </TABLE>")
$x = WriteLine( 3 , +" <P> </P>")

EXIT

Thank you.


Edited by Glenn Barnas (2014-11-14 12:57 PM)
Edit Reason: REMOVED code tags previously added due to conflict with HTML

Top
#209648 - 2014-11-14 03:00 PM Re: Disk Space Query [Re: Jasniel]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
I'd suggest you use single quotes for the Kix string definitions and the double-quotes for the HTML.

 Code:
If $DiskFree < $Min $Color = 'red' Else $Color = 'green' EndIf
$Rc = WriteLine(3, '{td}{font size="3" color="' + $Color + '"}' + $DiskFree + '{/font}{/td}')


Note the use of double + single and single + double quotes! Also, combine all of your font specifications and use a single "{/font}" tag to restore the settings.

Also note that I replaced the normal HTML tag chars with { and } to avoid issues with the display.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209649 - 2014-11-14 03:40 PM Re: Disk Space Query [Re: Glenn Barnas]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Thank you Glenn.

What about point 1? Any suggestion or solution for that?
1. I have the script that I have specified per MB is "$MB = 1048576". See detail of my script at the bottom of this post.

Following are the results:
Drive C has 130GB of free space, it output as 130.159145355225
Drive D has 728GB of free space, it output as 728.70979309082
Drive E has 3.6TB of free space, it ouput as -1958.04564285278

Top
#209650 - 2014-11-14 03:52 PM Re: Disk Space Query [Re: Jasniel]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Try replacing
$SMTITC = GetDiskSpace ("\\PC01\C$")
with
$SMTITC = 1.0 * GetDiskSpace("\\PC01\C$")
and
$MB = 1048576
with
$MB = 1048576.0

That will force the result to be a real, and you can eliminate the CDbl() functions.

Also, placing numbers in quotes forces them to be strings, which may result in comparisons different than what you expect.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209651 - 2014-11-15 07:12 AM Re: Disk Space Query [Re: Glenn Barnas]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Thank you Glenn for your help. Managed to resolved it by using ROUND.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.094 seconds in which 0.074 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org