egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Image downloader.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
geeker
Voice


Joined: 10 Dec 2013
Posts: 1

PostPosted: Tue Dec 10, 2013 9:46 pm    Post subject: Image downloader. Reply with quote

I wrote a script to download images posted from URLs to the channel, Im running this on a small VPS server (3Gb disk), im looking to figure out the best way to check if there is space available before it even attempts to download the image

so far this is what i've came up with.
Code:

proc freespace {} {
set dir /home
regexp {(\d+)} [lindex [lindex [split [exec df -k $dir] \n] end] end-2] -> kbytes
if {$kbytes > 1073741824} {
   set result [expr ${kbytes}.0 / 1073741824.0]; set sz "TB"
} elseif {$kbytes > 1048576} {
   set result [expr ${kbytes}.0 / 1048576.0] ; set sz "GB"
} else {
   set result [expr $kbytes / 1024.0] ; set sz "MB"
}
   set result "[format %.2f $result]${sz}"; puts $result
puts $kbytes
}

If the file cant be downloaded, it notifys the channel its too large.
The filesize given from the image site is in human-readable format
1.02MB. for example.
any ideas? thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber