I am trying to set up a custom script to monitor runtime and run this openssl command, and I have arguments that I pass to it.
openssl s_client -CAfile C:\apcerts\certs\ -quiet -connect ${HOST}:${PORT} > ${TMPF} 2>&1 < EOF <TF80DOC><XPLN/></TF80DOC> EOF if (Select-String "Update Level" ${TMPF} > /dev/null) { exitstatus=$STATE_OK Select-String "Update Level" ${TMPF} | sort | uniq} elseif (Select-String "Regulatory" ${TMPF} > /dev/null) { exitstatus=$STATE_OK Select-String "Regulatory" ${TMPF} | sort | uniq} else{ echo `date` >> /tmp/caught_errs.out cat ${TMPF} >> /tmp/caught_errs.out echo " " >> /tmp/caught_errs.out exitstatus=$STATE_CRITICAL } rm -f ${TMPF} 2> /dev/null exit ${exitstatus}
I want the variables $ {host}: $ {port} to remain empty, and I want to have an argument in which I manually put the information, and the fields are filled with this information.
for example, I need to connect to blank-xml.myinfo.comhaps0011.
The problem I am facing is when I install this on user monitors. I have a .bat that opens openssl but cannot open a .txt file to run the above commands.
what i need to do for this to work.
Update:
I made a batch file that passes information to openssl, which is much smaller.
@echo off c:\OpenSSL-Win64\bin\openssl s_client -connect help-xml.helpme.com:443
This section works fine, shows the necessary information on the screen. I need to send another command to the window, but get an error message <command is not an executable or batch process.
this command <TF80DOC><XPLN/></TF80DOC>
I tried to use the and symbol and used the echo before that, but I still get the same error or the screen will pop up and close instantly without any information.
the if then statement works after I run <TF80DOC><XPLN/></TF80DOC>
, since it has the information that is displayed that the operator is looking for. But if I canβt get <TF80DOC><XPLN/></TF80DOC>
to send to openssl after running s_client -connect help-xml.helpme.com:443
, then the if statement will never work.
Update:
I changed the powershell command to pipe in the command after s_client -connect help-xml.helpme.com:443
new code looks like
@' <TF90DOC><XPLN/></TF90DOC> '@ | C:\OpenSSL-Win64\bin\openssl s_client -quiet -connects_client -connect help-xml.helpme.com:443 > test1.txt 2>&1
the if statement is not a problem, since I know how to fix this part. The powershell part of the code works, but requires me to press the enter button, which is not what I need. I need it to execute the command automatically without user input
For the batch command, I made some minor changes to it:
@echo off setlocal enabledelayedexpansion set "var=<TF90DOC><XPLN/></TF90DOC>" echo echo !var! | C:\OpenSSL-Win64\bin\openssl s_client -connect tf90-xml.bsi.com:443> test1.txt 2>&1
this command still gives me an error
<was unexpected at the moment.