TE Alex | 4 Mar 23:20 2011
Picon

OpenSSL script automation

Dear OpenSSL dev

I am trying to connect to my gmail account using OpenSSL in the windows xp command prompt

I used the following command  syntax 
"c:\> openssl.exe s_client -quiet -crlf -connect imap.gmail.com:993


I now want to automate the  following :

login user <at> gmail.com password
. list "" "*"
. status inbox (messages)
. select inbox
. fetch 1 full
. logut


I tried a batch file (file.bat) contains the following :

"c:\> openssl.exe s_client -quiet -crlf -connect imap.gmail.com:993
login user <at> gmail.com password
. list "" "*"
. status inbox (messages)
. select inbox
. fetch 1 full
. logut

but it id not work


so, can you help me to automate my login and mail fetch in a script

thank you in advance

---------------------

soly
Dave Thompson | 7 Mar 02:52 2011

RE: OpenSSL script automation

>	From: owner-openssl-dev <at> openssl.org On Behalf Of TE Alex
>	Sent: Friday, 04 March, 2011 17:20

>	Dear OpenSSL dev

This is not a development (of OpenSSL) question.	

>	I am trying to connect to my gmail account using OpenSSL in the
windows xp command prompt 

>	I tried a batch file (file.bat) contains the following :
	
>	"c:\> openssl.exe s_client -quiet -crlf -connect imap.gmail.com:993"
>	. login user <at> gmail.com password
<snip rest>
	
>	but it id not work
>	so, can you help me to automate my login and mail fetch in a script

The command line in a Windows CMD .bat must be just the command;
you do NOT put the prompt C:\> (or similar) before it. And don't put 
the whole line in quotes, that treats the whole line as the program name,
which it isn't. If you need to specify a program name containing space(s), 
put quotes around the program name only, and similarly if an argument 
contains space(s), which most commonly occurs for filenames. For example, 
if you put your files in Windows-convention locations (which I don't 
particularly recommend) and DON'T have the exe dir in PATH, you might do:

"\program files\OpenSSL\openssl.exe" x509 -in "\xxx\My Documents\certfile"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this part is the program file name
this part is a data file name ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Programs run from a .bat file don't get their input from the .bat file, 
unlike a Unix shell script using "<<" which does.

If your desired input is fixed (not adaptive) the simplest way is to put it 
in a file and redirect openssl s_client to read from that file, with "<".

I expect there are more arcane (but possibly better) ways using ScriptHost, 
or PowerShell if M$ make that available on XP, or various other Windows 
tools -- inluding ports of Unix shells, or Unix-inspired tools like perl, 
to Windows. That is a general Windows question, not OpenSSL specific. 

PS- I'd be surprised if 'logut' works. More likely it's 'logout'.

PPS- You can use e.g. openssl rather than openssl.exe as a command (either 
interactive or in a .bat file) assuming you have the standard PATHEXT; 
that automatically tries .exe, .bat, and several other common extensions.
And similarly \path\to\openssl rather than \path\to\openssl.exe .
But it doesn't hurt to be explicit, and some consider it clearer.

PPPS- Having a CMD window and/or running programs with your current 
directory in the root C:\ is usually not a very good idea. It's too 
easy to accidentally use (or default to) a name that clobbers something 
important. Working in a data or even temporary directory is somewhat 
safer, although you can still destroy things if you try just a little.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev <at> openssl.org
Automated List Manager                           majordomo <at> openssl.org


Gmane