Go Back   FlashFXP Forums > > > >

! Requests Need a script or some sort of cool .bat file ? Ask here!

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-04-2005, 09:44 AM   #1
djdeluxe76
Member
 
Join Date: Mar 2005
Posts: 43
Default TCL script that parses file and converts date to timestamp

Hello and thank you for reading this request post.

I was going to do/learn it myself but I just wind up dead .... its just
too much for the beginning.

Though I can feel for a pro this should not be much work especially
because I just need a basic script I can do the bug tracking myself
and learn something at the same time.

Basically it's just

1. open file,
2. parse (regexp) for YYYY-MM-DD HH:NN (2005-05-04 12:15)
3. and convert to unix epoch timestamp like (1114708730)

Anyone, please, with too much freetime at hands?

Much apreciated !!

Cheers
DJ

p.s.: I searched the forum with terms 'script convert timestamp' and
'convert timestamp' so i'm sorry if i've overlooked a post.
djdeluxe76 is offline   Reply With Quote
Old 05-04-2005, 12:44 PM   #2
jeza
Senior Member
ioFTPD Scripter
 
jeza's Avatar
 
Join Date: May 2003
Posts: 530
Default

Code:

set time_now		[clock seconds]
set time_formated	[clock format $time_now -format {%Y-%m-%d %H:%M:%S} -gmt true]
set file_time		""
set file_formated	""

if { [file exist "x:/path/file"] } {

  set reply [open "x:/path/file" "r+"]
  
  while {![eof $reply]} {
    
    set line [gets $reply]
    
    if { [regexp -nocase -- {[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}} $line out] } {
      
      set file_time		$out
      set file_formated		[clock scan "$out" -gmt true]
      
      iputs -nobuffer "time_now......: $time_now"
      iputs -nobuffer "time_formated.: $time_formated"
      iputs -nobuffer "line..........: $line"
      iputs -nobuffer "file_time.....: $file_time"
      iputs -nobuffer "file_formated.: $file_formated"
      
      
    }
    
  }
  
  close $reply
  
}
jeza is offline   Reply With Quote
Old 05-04-2005, 03:08 PM   #3
djdeluxe76
Member
 
Join Date: Mar 2005
Posts: 43
Smile

hello Jeza

Thanks for replying so quickly giving me a beatiful insight here

I just found something called the Active TCL Manual so I guess its time
now to learn some stuff (read functions) you have used here..

When I finally get home I'm all eager to experiment with your code.

Thank you!
DJ
djdeluxe76 is offline   Reply With Quote
Old 05-04-2005, 04:52 PM   #4
djdeluxe76
Member
 
Join Date: Mar 2005
Posts: 43
Default

one question though if you dont mind.... i can't seem to find "iputs" only "puts" ... what is the difference in this case please?

cheers
DJ
djdeluxe76 is offline   Reply With Quote
Old 05-04-2005, 05:04 PM   #5
neoxed
Too much time...
FlashFXP Beta Tester
ioFTPD Scripter
 
Join Date: May 2003
Posts: 1,326
Default

The "iputs" command is provided by ioFTPD, to write to the control channel.

For a list of other ioFTPD specific Tcl commands, check the following posts:

http://www.ioftpd.com/board/showthre...=&threadid=230
http://www.ioftpd.com/board/showthre...&threadid=1775
neoxed is offline   Reply With Quote
Old 05-04-2005, 06:12 PM   #6
djdeluxe76
Member
 
Join Date: Mar 2005
Posts: 43
Default

ahh i understand. Thanks for pointing me in the right direction

thanks to you both guys!

Cheers
DJ
djdeluxe76 is offline   Reply With Quote
Reply

Tags
convert, file, post, script, timestamp

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:49 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)