Tag Archives: quick code

simple email procedure for tcl in linux or unix system

Quick Code:
Here is a sample procedure for tcl that you can use to send email. This basically call the mail function built in linux or unix like system.
Usage: gQuickMail “subject” “sendToEmailAdress” “bodyMessage” “ccToEmail” “bccToEmail”
Git: git clone https://github.com/rvguiman/tcl.git (added in g_misc_utility.tcl)
Or Check the code below

proc gQuickMail { subject sendTo bodyMsg ccTo bccTo } {
        set qmsgHan [open "tempMsg.qmsg" w]
        puts $qmsgHan $bodyMsg
        close $qmsgHan
        puts "sending mail...."
        if { $ccTo != "" && $bccTo != "" } {
                catch { exec mail -s $subject -c $ccTo -b $bccTo $sendTo < tempMsg.qmsg } msg
                } elseif { $ccTo != "" && $bccTo == "" } {
                catch { exec mail -s $subject -c $ccTo $sendTo < tempMsg.qmsg } msg
                } elseif { $ccTo == "" && $bccTo != "" } {
                catch { exec mail -s $subject -b $bccTo $sendTo < tempMsg.qmsg } msg
                } else {
                catch { exec mail -s $subject $sendTo < tempMsg.qmsg } msg
                }
        puts $msg
        catch { exec rm -rf tempMsg.qmsg } msg
        puts $msg
        puts "closing gQMail"
        }

get file date in tcl

Quick Code:
This is a simple tcl script procedure to get the date of a file. The return value is a list containing time in seconds and human readable time in string.

Usage:¬†getFileDate “/docs/sample/test.txt”
Git: git clone https://github.com/rvguiman/tcl.git (added in g_file_utility.tcl)
Or check the code below

proc gGetFileDate { filePass } {
    set secTime [file mtime $filePass]
    set humanTime [clock format $secTime -format "%d_%b_%y_%H:%M:%S"]
    return [list $secTime $humanTime]
    }