: ) wonderful world ( :

the metasyntactic variable

Archive for the ‘windowns’ Category

snippet to build word docs from excel data

leave a comment »

This should be run in Word’s VBA project…

Sub WordFromExcel()
   ' one single Excel is open with the workbook we want to read from
   Set ex = GetObject(,"Excel.Application")
   Set book = ex.ActiveWorkbook
   Set sheet = book.Sheets(1)

   With Selection
      ' insert some heading
      .ParagraphFormat.Style = Word.WdBuiltinStyle.wdStyleHeading1
      .TypeText Text:=sheet.Name
      .TypeParagraph

      ' insert text from the cells
      .ParagraphFormat.Style = Word.WdBuiltinStyle.wdStyleNormal
      .TypeText Text:=sheet.Cells(1, 1).Value
      .TypeParagraph
   End With

   Set sheet = Nothing
   Set book = Nothing
   Set ex = Nothing
End Sub

Written by grault

December 10, 2010 - 6:24 pm at December 10, 2010 - 6:24 pm

graph algorithms with GraphViz and agraph

leave a comment »

% find
.
./bin
./bin/cdt.dll
./bin/graph.dll
./bin/sample.gv
./incomings.c
./Makefile

%

 

These are the files from this hello world project. The dlls are from the GraphViz installation directory (from bin/). The task is to collect incoming nodes for a given other node (the ones that have directed edges into the selected one). The good thing in this is that you don’t have to design you own graph markup language and your own parser (NIH). Instead you can use the well defined and supported dot language from GraphViz. I’ve used MingW and MSYS as development environment.

% cat -A Makefile
all:^Iincomings.exe$
$
incomings.exe:^Iincomings.o$
^Ig++ $< -O2 -o bin/$@ `PKG_CONFIG_PATH=c:/Graphviz2.24/lib/pkgconfig/ pkg-confi
g --libs libgvc`$
$
incomings.o:^Iincomings.c$
^Ig++ $< -O2 -c -o $@ `PKG_CONFIG_PATH=c:/Graphviz2.24/lib/pkgconfig/ pkg-config
 --cflags libgvc`$
$
clean:$
^Irm -rf incomings.o bin/incomings.exe$
$
test:^Iall$
^Ibin/incomings.exe bin/sample.gv a$

% cat incomings.c
#include<gvc.h>

char* gv_gets(char *buf, int n, FILE* fp)
{
  return fgets(buf,n,fp);
}

int main (int argc, char **argv)
{
  Agraph_t *g;
  Agnode_t *n;
  Agedge_t *e;
  FILE *fp;

  if(argc > 2)
    fp=fopen(argv[1],"r");
  else
    fp=stdin;

  aginit();
  g=agread_usergets(fp,gv_gets);
  for(n=agfstnode(g);n;n=agnxtnode(g,n))
    if(strcmp(n->name,argv[argc-1])==0)
      for(e=agfstin(g,n);e;e=agnxtin(g,e))
        printf("%s\n",e->tail->name);

  agclose(g);
  return 0;
}

% make
g++ incomings.c -O2 -c -o incomings.o `PKG_CONFIG_PATH=c:/Graphviz2.24/lib/pkgco
nfig/ pkg-config --cflags libgvc`
g++ incomings.o -O2 -o bin/incomings.exe `PKG_CONFIG_PATH=c:/Graphviz2.24/lib/pk
gconfig/ pkg-config --libs libgvc`

% cat bin/sample.gv
digraph G
{
  b -> a;
  c -> a;
  d -> a;
  e -> a;
  f -> a;
  a -> foo;
}

% make test
g++ incomings.o -O2 -o bin/incomings.exe `PKG_CONFIG_PATH=c:/Graphviz2.24/lib/pk
gconfig/ pkg-config --libs libgvc`
bin/incomings.exe bin/sample.gv a
b
c
d
e
f

%

Written by grault

November 10, 2009 - 4:10 pm at November 10, 2009 - 4:10 pm

Posted in windowns

rebuild cffi foreign bindings

leave a comment »

C:\grault>type lib-foo.c
int getone ()
{
   return 1;
}

C:\grault>gcc -shared -o lib-foo.dll lib-foo.c

C:\grault>clisp -q -norc -i ..\.clisprc
;; Loading file ..\.clisprc ...
[1]> (setf *load-verbose* nil)
NIL
[2]> (asdf:oos 'asdf:load-op :cffi :verbose nil)
#<ASDF:LOAD-OP (:VERBOSE NIL) #x19C29B55>
[3]> (cffi:load-foreign-library "lib-foo")
#<CFFI::FOREIGN-LIBRARY #x19CCE065>
[4]> (cffi:defcfun  "getone" :int)
GETONE
[5]> (getone)
1
[6]> (ext:saveinitmem "foo.mem" :norc t)

Bytes permanently allocated:             92,512
Bytes currently in use:               3,409,664
Bytes available until next GC:          852,166
3409664 ;
852166 ;
92512 ;
38 ;
20303572 ;
2808018
[7]> (quit)

C:\grault>dir/b
foo.mem
lib-foo.c
lib-foo.dll

C:\grault>clisp -q -M foo.mem
[1]> (getone)
WARNING: FFI::FIND-FOREIGN-FUNCTION: no dynamic object named "getone" in library :DEFAULT
*** - FUNCALL: undefined function NIL
The following restarts are available:
USE-VALUE      :R1      Input a value to be used instead of (FDEFINITION 'NIL).
RETRY          :R2      Retry
STORE-VALUE    :R3      Input a new value for (FDEFINITION 'NIL).
ABORT          :R4      Abort main loop
Break 1 [2]> :r4
[3]> (cffi:use-foreign-library "lib-foo")
#<CFFI::FOREIGN-LIBRARY #x19FB66AD>
[4]> (getone)
1
[5]> (quit)

C:\grault>

Written by grault

November 3, 2009 - 1:29 pm at November 3, 2009 - 1:29 pm

Posted in lisp, session, windowns

common lisp GUI-application shipment&delivery on windows

leave a comment »

First of all, here’s the lisp I’ve used:

% clisp --version | grep -v ^Machine
GNU CLISP 2.48 (2009-07-28) (built on stnt067 [192.168.0.1])
Software: GNU C 3.4.5 (mingw-vista special r3)
gcc -mno-cygwin -O2 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-ty
pe -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O2 -fexpensi
ve-optimizations -falign-functions=4 -D_WIN32 -DUNICODE -DDYNAMIC_FFI -I.  -lint
l -lreadline -ltermcap -lavcall -lcallback -luser32 -lws2_32 -lole32 -loleaut32
-luuid -liconv -lsigsegv
SAFETY=0 HEAPCODES STANDARD_HEAPCODES GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRI
VIALMAP_MEMORY
libsigsegv 2.6
libiconv 1.11
libreadline 5.2
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS
 LOGICAL-PATHNAMES SCREEN FFI GETTEXT UNICODE BASE-CHAR=CHARACTER PC386 WIN32)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: C:\Program Files\clisp-2.48\
User language: ENGLISH

%

 

I have also MingW (5.1.6) and MSYS (1.0.1) installed, Witchs Hat icon downloaded, CLisp dlls copied from the base subdirectory under the installation path. This is the development tree in clean form:

% find
.
./bootstrapper.cc
./bootstrapper.rc
./clisp-dlls
./clisp-dlls/libiconv-2.dll
./clisp-dlls/libintl-8.dll
./clisp-dlls/readline5.dll
./Makefile
./message.lisp
./witchs-hat.ico
%

 

Under clisp-dlls, there are the mentioned dlls of CLisp. The file message.lisp contains the program you’d like to run (or ship or whatever). Finally, the bootstrapper files are up to provide an exe with company info, icon, copyright, etc. as an entry to the lisp program. The important bit here is that you don’t want a command prompt window popping up before startup.
Let’s see the files:

% cat message.lisp
(use-package "FFI")
(def-call-out messagebox
  (:name "MessageBoxA") (:library "user32.dll")
  (:arguments (hwnd int) (text c-string) (capt c-string) (type uint))
  (:return-type int)
  (:language :stdc))

(defun main ()
  (messagebox 0 "Your hacking starts... NOW!" "Demo MsgBox" 0)
  (quit))
% cat -A Makefile
all:^Imsgbox-app.exe msgbox-app.img$
^Imkdir -p shipment$
^Icp msgbox-app.exe shipment$
^Icp msgbox-app.img shipment$
^Icp clisp-dlls/* shipment$
$
msgbox-app.img:^Imsgbox-app.img.exe$
^Icp $< $@$
$
msgbox-app.img.exe:^Imessage.lisp$
^Iclisp -q -norc -x \$
"(load \"message.lisp\") \$
(ext:saveinitmem #P\"./msgbox-app.img.exe\" \$
                 :executable t \$
                 :norc t \$
                 :init-function #'main)"$
$
bootstrapper.res:^Ibootstrapper.rc witchs-hat.ico$
^Iwindres $< -O coff -o $@$
^I$
msgbox-app.exe:^Ibootstrapper.cc bootstrapper.res$
^Ig++ -mwindows $^ -o $@$
$
clean:$
^Irm -rf msgbox-app.exe bootstrapper.res \$
^Imsgbox-app.img msgbox-app.img.exe shipment$
% cat bootstrapper.rc
ID ICON "witchs-hat.ico"
1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "080904E4"
    BEGIN
      VALUE "CompanyName", "MsgBox Products"
      VALUE "FileDescription", "Demo MsgBox"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "msgbox-app"
      VALUE "LegalCopyright", "Grault"
      VALUE "OriginalFilename", "msgbox-app.exe"
      VALUE "ProductName", "Demo MsgBox"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x809, 1252
  END
END
% cat bootstrapper.cc
#include <windows.h>

int WinMain(HINSTANCE a0, HINSTANCE a1, LPSTR a2, int a3)
{
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  ZeroMemory(&si,sizeof(STARTUPINFO));
  si.cb = sizeof(STARTUPINFO);
  CreateProcess("msgbox-app.img", "",
     NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,
     NULL,&si,&pi);
  // version and company details are in the bootstrapper exe
  // it's kinda better to show these e.g. in process explorer
  // and image file as a subprocess
  // feel free to comment the following line to leave img only
  WaitForSingleObject(pi.hProcess, INFINITE);
  return 0;
}
%

 

These are the files, and here are the results of a make:

% make
windres bootstrapper.rc -O coff -o bootstrapper.res
g++ -mwindows bootstrapper.cc bootstrapper.res -o msgbox-app.exe
clisp -q -norc -x \
"(load \"message.lisp\") \
(ext:saveinitmem #P\"./msgbox-app.img.exe\" \
                 :executable t \
                 :norc t \
                 :init-function #'main)"
;; Loading file message.lisp ...
;; Loaded file message.lisp
T
;; Wrote the memory image into .\msgbox-app.img.exe (5,088,157 bytes)
Bytes permanently allocated:             92,512
Bytes currently in use:               2,188,704
Bytes available until next GC:          544,546
2188704 ;
544546 ;
92512 ;
1 ;
52160 ;
156001
cp msgbox-app.img.exe msgbox-app.img
mkdir -p shipment
cp msgbox-app.exe shipment
cp msgbox-app.img shipment
cp clisp-dlls/* shipment
% find
.
./bootstrapper.cc
./bootstrapper.rc
./bootstrapper.res
./clisp-dlls
./clisp-dlls/libiconv-2.dll
./clisp-dlls/libintl-8.dll
./clisp-dlls/readline5.dll
./Makefile
./message.lisp
./msgbox-app.exe
./msgbox-app.img
./msgbox-app.img.exe
./shipment
./shipment/libiconv-2.dll
./shipment/libintl-8.dll
./shipment/msgbox-app.exe
./shipment/msgbox-app.img
./shipment/readline5.dll
./witchs-hat.ico

 

Here’s a picture how this all looks like on a Windows Server 2003 Standard Edition without any kind of lisp installed. And the entries in Process Explorer.

shipped

Some sort of shipment : )


shipped-pe

show up in Process Explorer

Obviously one can develop a much more sophisticated bootstrapper. This one represents only the possibility of releasing software written in Lisp. Assembling these output files together into an installer could be the next step : ))

 

And finally, you can get either the binaries or the source files by sending a mail to:

% echo gra.rtebsrpehbf.ferfh@gyhnet | rev | tr '[a-z]' '[n-za-m]'

Written by grault

October 30, 2009 - 5:38 pm at October 30, 2009 - 5:38 pm

7zip loads of files in a single folder

leave a comment »

I’ve met with a folder with around 400000 files on Windows. Listing the files takes more than 5 minutes for an explorer window which is infinity in IT terms : ) Setting the working directory to this one in a cmd window works. Great. Starting a dir command in cmd leads to this infinity of silence also. Suprisingly if your file names are structured enough to hash them with a prefix, then `dir prefix1*’ is relatively fast. Therefore creating directories for the values and moving the groups to these solves the problem somewhat. I also decided to zip these folders of grouped files (by a hash on their names). 7z run time somehow depends on the nr of files in current directory even if you’re up to compress the files in a single subdirectory into a file which is in the current working one. This can be an issue when you have hundreds of thousands files in a single directory. So it’s better to separate the files first and compress them after.

Here’s the batch file I’ve used to solve this.

set list=^
200801 200802 200803 200804 200805 200806 ^
200807 200808 200809 200810 200811 200812 ^
200901 200902 200903 200904 200905 200906 ^
200907 200908 200909

for %%i in (%list%) do (
md archive_%%i
move someprefix%%i* archive_%%i\
)


for %%i in (%list%) do (
7z a archive_%%i.7z archive_%%i\
)

Written by grault

October 22, 2009 - 1:37 pm at October 22, 2009 - 1:37 pm

Posted in command line, windowns

word docx file from lisp

leave a comment »

Due to the rdnzl .net layer for common lisp, you’re able to use the word interop assemblies and do full word or office automation through lisp. There’s only an Excel query type example on that page. This is a creational pattern for Word:

C:\notes\my-asdf-packs\cl-docx-sandbox>type cl-docx-sandbox.asd
(defsystem cl-docx-sandbox
  :components ((:file "just-do-it"))
  :depends-on (rdnzl cl-def))
C:\notes\my-asdf-packs\cl-docx-sandbox>type just-do-it.lisp

(defpackage :cl-docx-sandbox
  (:use :cl :cl-def)
  (:export #:one-liner-word))

(in-package :cl-docx-sandbox)

(def load-time-constant +miss+ (rdnzl:field "System.Reflection.Missing" "Value"))

(def function word-save-as (doc filename)
     (rdnzl:invoke doc "SaveAs"
                   (rdnzl:ref filename)
                   (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+)
                   (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+)
                   (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+)
                   (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+)
                   (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+)))

(def (function e) one-liner-word (filename line)
     (progn
       (rdnzl:import-types "Microsoft.Office.Interop.Word"
                           "Document" "ApplicationClass" "Documents" "DocumentClass")
       (let* ((app (rdnzl:new "Microsoft.Office.Interop.Word.ApplicationClass"))
              (doc (rdnzl:invoke (rdnzl:property app "Documents") "Add"
                                 (rdnzl:ref +miss+) (rdnzl:ref +miss+)
                                 (rdnzl:ref +miss+) (rdnzl:ref +miss+)))
              (sel (rdnzl:property app "Selection")))
         (progn
           (rdnzl:invoke sel "TypeText" line)
           (rdnzl:invoke sel "TypeParagraph")
           (word-save-as doc filename)
           (rdnzl:invoke doc "Close"
                          (rdnzl:ref +miss+) (rdnzl:ref +miss+) (rdnzl:ref +miss+))))))

C:\notes\my-asdf-packs\cl-docx-sandbox>

 

Usage:

CL-USER> (asdf:oos 'asdf:load-op :cl-docx-sandbox)
; lots of stuff
; [...]
CL-USER> (cl-docx-sandbox:one-liner-word "c:\\one-liner.docx" "Hello World!")
:VOID
CL-USER> 

 

The result is:
one-liner.docx

Written by grault

July 16, 2009 - 3:39 pm at July 16, 2009 - 3:39 pm

Posted in lisp, windowns

office open xml file sample

leave a comment »

Here‘s the spec.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
  <pkg:part
    pkg:name="/_rels/.rels"
    pkg:contentType="application/vnd.openxmlformats-package.relationships+xml">
    <pkg:xmlData>
      <Relationships
        xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
        <Relationship
          Id="foo"
          Type=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
          Target="/word/document.xml"/>
      </Relationships>
    </pkg:xmlData>
  </pkg:part>
  <pkg:part
    pkg:name="/word/document.xml"
    pkg:contentType=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
    <pkg:xmlData>
      <w:document
        xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
        <w:body>
          <w:p>
            <w:r>
              <w:t>Hello World</w:t>
              <w:br />
              <w:yearLong />
            </w:r>
          </w:p>
        </w:body>
      </w:document>
    </pkg:xmlData>
  </pkg:part>
</pkg:package>

Written by grault

June 25, 2009 - 12:43 pm at June 25, 2009 - 12:43 pm

Posted in windowns

ms access relations into graphviz

with 23 comments

Today is a scripting day : )

If you have to maintain a large MS Access database (manipulate data in it) with complex relationship matrix, the built-in relations diagram is quite useless. This is because Access won’t compute a proper layout. It just displays the nodes (the tables) next to each other and draw all the edges. Period. An idea is to dump these relations into a graphviz .dot file and let graphviz do the layout. This solution is very useful if you want to understand a complex database represented in Access.

C:\Users\grault\Desktop>dir/b test.accdb
test.accdb

C:\Users\grault\Desktop>type dumpRelationship.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objAcc = CreateObject("Access.Application")
fileName = objFSO.GetAbsolutePathName(WScript.Arguments.Item(0))
outName = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))

objAcc.OpenCurrentDatabase(fileName)
Set outFile = objFSO.CreateTextFile(outName)

outFile.WriteLine ("digraph G { graph [rankdir=""LR""];")
For Each tbl In objAcc.CurrentDb.Tabledefs
   If LCase(Left(tbl.Name, 4)) <> "msys" Then
     entry = """" & tbl.Name & """ [label=""<" & tbl.Name & "> " & tbl.Name
     For Each fi In tbl.Fields
       entry = entry & "| <" & fi.Name & "> " & fi.Name
     Next
     entry = entry & """ shape=""record""];"
     outFile.WriteLine(entry)
   End If
Next

For Each rel In objAcc.CurrentDb.Relations
  For Each fld In rel.Fields
    arrow = """" & rel.Table & """:" & fld.Name & " -> " & _
            """" & rel.ForeignTable & """:" & fld.ForeignName & _
            " [arrowhead=""odotodot"" arrowtail=""orboxrtee""];"
    outFile.WriteLine(arrow)
  Next
Next

outFile.WriteLine("}")
outFile.Close
objAcc.CloseCurrentDataBase
objAcc.Quit

C:\Users\grault\Desktop>dumpRelationship.vbs test.accdb test.dot

C:\Users\grault\Desktop>type test.dot
digraph G { graph [rankdir="LR"];
"Table1" [label="<Table1> Table1| <ID> ID| <Desc> Desc" shape="record"];
"Table2" [label="<Table2> Table2| <ID> ID| <Ref1> Ref1| <OtherDesc> OtherDesc"
shape="record"];
"Table1":ID -> "Table2":Ref1 [arrowhead="odotodot" arrowtail="orboxrtee"];
}

C:\Users\grault\Desktop>dot -Tpng -o test.png test.dot

(dot.exe:6480): Pango-WARNING **: couldn't load font
"Times Roman Not-Rotated 14 ",
falling back to "Sans Not-Rotated 14", expect ugly output.

C:\Users\grault\Desktop>

 

the result

the result

Written by grault

May 15, 2009 - 4:14 pm at May 15, 2009 - 4:14 pm

Posted in notes, script, windowns

concatenate or merge docx Word files dot vbs

with 2 comments

Update: at the bottom, I’ve inserted some screenshots, how to really see the merged document (and probably print it). The technology used here is master documents..

 

In case you have generated Word files which are parts of a future “master” document and also you want to automate the process of assembling them together by writing some sort of build script, the following snippet is probably useful. Generating documents is good to avoid redundancy. In case you have to have a document in which parts can be computed based on other parts (with also the miserable contraint on document format and production environment) , it’s good to consider splitting the document, generating the parts and assembling them at the end. And now, the code:

C:\Users\grault\Desktop\a>dir/b
a1.docx
a2.docx
build.vbs

C:\Users\grault\Desktop\a>type build.vbs
Set objWord = CreateObject("Word.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objDoc = objWord.Documents.Add()

objDoc.ActiveWindow.View.Type = 2 'wdOutlineView
For I = 1 To WScript.Arguments.Count - 1
   objDoc.Subdocuments.AddFromFile _
     (objFSO.GetAbsolutePathName(WScript.Arguments.Item(I)))
Next

objDoc.SaveAs(objFSO.GetAbsolutePathName(WScript.Arguments.Item(0)))
objWord.Quit
C:\Users\grault\Desktop\a>build.vbs out.docx a1.docx a2.docx

C:\Users\grault\Desktop\a>dir/b
a1.docx
a2.docx
build.vbs
out.docx

C:\Users\grault\Desktop\a>

 

Entry at (2010/01/07):

a1.docx

a2.docx

out.docx opened fresh

change to outline view

click on the "Show Document" button

you'll get this view (or similar : )

click on the "Expand Subdocuments" button

finally you'll get the contents visible

now you can change the view (or print the document)

Written by grault

May 15, 2009 - 9:46 am at May 15, 2009 - 9:46 am

Posted in notes, script, windowns

command line gmail; msmtp; 465

with 3 comments

Just a few words about my attempt to use Gnus with msmtp. The first step was to launch msmtp without Gnus from command line. There are three ports related to smtp protocol: 25, 465, 587. Usually 25 is the plain smtp without encryption, the difference between the other two is that 587 uses TLS encryption and 465 uses SSL encryption. 587 is filtered in some way on my network (telnet to that port times out), so 465 is the one I use. The majority of examples and tutorials use 587, so I tried using those config files and steps but the port. The most important difference is in the .msmtprc file:

account gmail
host smtp.gmail.com
tls on
tls_certcheck off
tls_starttls off # this is the most important difference
port 465 # not using 587
auth on
user username # without the 'at gmail dot com'
from username@gmail.com
password your_password_connected_to_username

 

Without this most important change msmtp just hangs after printing out “reading recipients from the command line” which is really annoying because there’s no good search results on google what to do in such situations. With previous config file I was able to run msmtp as follows:

$ cat mail.txt
To: grault@do-not-send-mail-here.com
Subject: test msmtp
From: XY <no-such-user@gmail.com>
User-Agent: The command line MSMTP

test MSMTP

--
BRs,
Grault
$ msmtp -d -C .msmtprc -a gmail grault@do-not-send-mail-here.com < mail.txt
ignoring system configuration file C:\ProgramData\msmtprc.txt: No such file or d
irectory
loaded user configuration file .msmtprc
using account gmail from .msmtprc
host                  = smtp.gmail.com
port                  = 465
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = choose
user                  = no-such-user
password              = *
ntlmdomain            = (not set)
tls                   = on
tls_starttls          = off
tls_trust_file        = (not set)
tls_crl_file          = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = off
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
auto_from             = off
maildomain            = (not set)
from                  = no-such-user@gmail.com
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = (not set)
syslog                = (not set)
reading recipients from the command line
TLS certificate information:
    Owner:
        Common Name: smtp.gmail.com
        Organization: Google Inc
        Locality: Mountain View
        State or Province: California
        Country: US
    Issuer:
        Common Name: Thawte Premium Server CA
        Organization: Thawte Consulting cc
        Organizational unit: Certification Services Division
        Locality: Cape Town
        State or Province: Western Cape
        Country: ZA
    Validity:
        Activation time: Mon Jul 30 02:00:00 2007
        Expiration time: Fri Jul 30 01:59:59 2010
    Fingerprints:
        SHA1: 5E:F7:E8:CE:1A:BE:D8:94:F2:77:45:5D:ED:38:46:4F:5D:D1:97:61
        MD5:  F1:D3:DE:59:9D:9C:E2:31:EA:AA:2C:A0:FC:AD:9A:61
<-- 220 mx.google.com ESMTP 37sm7124747yxl.35
--> EHLO localhost
<-- 250-mx.google.com at your service, [187.97.152.29]
<-- 250-SIZE 35651584
<-- 250-8BITMIME
<-- 250-AUTH LOGIN PLAIN
<-- 250-ENHANCEDSTATUSCODES
<-- 250 PIPELINING
--> AUTH PLAIN AVL4YWLvbGNuLnN6sWQzAGWkc2Z8eHN6rg==
<-- 235 2.7.0 Accepted
--> MAIL FROM:<no-such-user@gmail.com>
--> RCPT TO:<grault@do-not-send-mail-here.com>
--> DATA
<-- 250 2.1.0 OK 37sm7124747yxl.35
<-- 250 2.1.5 OK 37sm7124747yxl.35
<-- 354  Go ahead 37sm7124747yxl.35
--> To: grault@do-not-send-mail-here.com
--> Subject: test msmtp
--> From: XY <no-such-user@gmail.com>
--> User-Agent: The command line MSMTP
-->
--> test MSMTP
-->
--> --
--> BRs,
--> Grault
--> .
<-- 250 2.0.0 OK 1240471557 37sm7124747yxl.35
--> QUIT
<-- 221 2.0.0 closing connection 37sm7124747yxl.35
$ msmtp --version
msmtp version 1.4.17
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
plain cram-md5 digest-md5 external login ntlm
IDN support: enabled
NLS: disabled
Keyring support: none
System configuration file name: C:\ProgramData\msmtprc.txt
User configuration file name: c:\users\grault\msmtprc.txt

Copyright (C) 2008 Martin Lambers and others.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
$ pwd
/cygdrive/c/users/grault
$

Written by grault

April 23, 2009 - 8:40 am at April 23, 2009 - 8:40 am

Follow

Get every new post delivered to your Inbox.