Error when try to send email with sendEmail - email

I want to use sendEmail to send automated emails.
If i run the following line separately it works:
sendemail.exe -f "payslip#dgroup.com" -t "dn.john#dgroup.com" -u "Payslip: DN JOHN, marca 1567, may 2021" -o message-file=mail_body_payslip.txt -o tls=no -o username="payslip#dgroup.com" -o password="hfsjfb&^%" -s webmail.dgroup.com:26 -o timeout=5 -xu payslip#dgroup.com -xp hfsjfb&^% -a "C:\Payslips\encrypted\2021_05_1702_DN_JOHN.pdf" -l email_log.txt
However if i try to run it from a bat file it doesn't work.
Here is the bat file:
#echo.
#echo.
echo Starting email session... >> email_log.txt
date /t >> email_log.txt
time /t >> email_log.txt
#echo.
#echo Verifying files...
#echo.
#echo Sending mails...
sendemail.exe -f "payslip#dgroup.com" -t "dn.john#dgroup.com" -u "Payslip: DN JOHN, marca 1567, may 2021" -o message-file=mail_body_payslip.txt -o tls=no -o username="payslip#dgroup.com" -o password="hfsjfb&^%" -s webmail.dgroup.com:26 -o timeout=5 -xu payslip#dgroup.com -xp hfsjfb&^% -a "C:\Payslips\encrypted\2021_05_1702_DN_JOHN.pdf" -l email_log.txt
#echo.
#echo.
#echo Payslip was sent. Verify email_log.txt
#echo.
#pause
When i run the bat file I get the following error:
Jun 16 14:01:55 srv3 sendemail.exe[2532]: ERROR => Connection attempt to localhost:25 failed: IO::Socket::INET: connect: Unknown error
If I run telnet localhost:25 I get this:
Could not open connection to the host, on port 23: Connect failed
What could be the problem? Why is running fine separately but executed from bat file I get error?

I've found the problem.
When you run the bat file the "%" character found in the password was replaced with "26" therefore the password was incorrect.
The solution is to use %% instead of %.
Two %% equals to one %.

Related

Powershell command certUtil ssh and exitCode

I have a problem with a powershell command :
powershell -command "& { ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=2 server#server -x -p 22 CertUtil -hashfile program.jar MD5 }"
I've got this response :
CertUtil: -hashfile command FAILED: 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
CertUtil: The system cannot find the file specified.
That is the response I want. BUT this is not an error code. It is an output message. And the LastExitCode is '0'.
I need a true error code without analyzing the output message.
I tried to manipulate the command but without success. I don't understand why the generated error does not throw a real error in Powershell.
It seems that if I use this command (with the use of execution policy), I get a non '0' exit code. It may be a goot solution even if I'm not sure of the reason why. Many thanks for your help.
powershell -ExecutionPolicy Bypass -Command "& ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=2 server\server -x -p 22 CertUtil -hashfile program.jar MD5"; echo $LASTEXITCODE
CertUtil: -hashfile command FAILED: 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
CertUtil: The system cannot find the file specified.
1

kubectl exec: Permission denied

Try to append some new entries to /etc/hosts in pods, but failed:
$ ips=$(cat ips.txt); kubectl exec -u root myspark-master-5d6656bd84-5zf2h echo "$ips" >> /etc/hosts
-sh: /etc/hosts: Permission denied
How to fix this?
Thanks
UPDATE
$ ips=$(cat ips.txt); kubectl exec myspark-worker-5976b685b4-8bcbl -- sh -c "echo $ips >> /etc/hosts"
sh: 2: 10.233.88.5: not found
sh: 3: 10.233.96.2: not found
sh: 4: 10.233.86.5: not found
10.233.88.4 myspark-master-5d6656bd84-dxhxc
command terminated with exit code 127
I think you mean to write to the file inside the container, but bash is parsing that on your workstation and try to apply the redirect locally. Use kubectl exec ... -- sh -c “...” instead.
There is indeed a parsing problem because $ips contain new lines.
Try with
$ ips=$(cat ips.txt); kubectl exec myspark-worker-5976b685b4-8bcbl -- sh -c "echo \"$ips\" >> /etc/hosts"

PostgreSQL: Automated Backup in Windows

I'm trying to create an automated backup in Postgresql using below link, but I don't know where to find the needed dll, I'm stuck here. Can't proceed to next instruction because of this. Can anyone knows how to do it? Need help please.
https://wiki.postgresql.org/wiki/Automated_Backup_on_Windows
comerr32.dll
gssapi32.dll
k5sprt32.dll
krb_32.dll
libeay32.dll
libiconv2.dll
libpq.dll
Microsoft.VC80.CRT.manifest
msvcm80.dll
msvcp80.dll
msvcr80.dll
pg_dump.dll
ssleay32.dll
zlib1.dll
Here's batch file script:
#echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
echo datestr is %datestr%
set BACKUP_FILE=<backup_name_>_%datestr%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=<password>
echo on
bin\pg_dump -i -h <localhost> -p 5432 -U <postgres> -F c -b -v -f %BACKUP_FILE% <db_name>
Is there missing syntax?
When manually executed error shows:
bin\pg_dump: illegal option -- i
I execute something like this
pg_dump.exe -h %SERVER% -p 5432 -U postgres -Fc -d %basedatos% -v -f %filebackup%
This variables replace value respective.

command work in command prompt but not in batch file

I am trying to send out email attachment periodically from a batch script using this command line client
http://caspian.dotconf.net/menu/Software/SendEmail
the command for it is pretty straightforward
sendEmail -t abc#gmail.com -u hellp -f abd#nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstu\a123456 -xp helloworld! -a C:\Users\ll\Desktop\Quotes.docx
The strange thing is if I type that line in command prompt, it works perfectly fine. I can
receive the email with attachment.
However, when I put it into a batch script, like
:email
sendEmail -t abc#gmail.com -u hellp -f abd#nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstu\a123456 -xp helloworld! -a C:\Users\ll\Desktop\Quotes.docx
goto:eof
and I call this subroutine in my batch file, the output says
SMTP:AUTH authentication to smtp.nus.edu.sg:25 failed.
I checked. no typo, Could someone help me what is the difference? why the same command works in command line but cause trouble in a script file?
Thanks
I believe you're censoring your batch too much.
Try running the following:
#ECHO OFF
setlocal
echo sendEmail -t abc#gmail.com -u hellp -f abd#nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstu\a123456 -xp helloworld! -a C:\Users\ll\Desktop\Quotes.docx
endlocal
SETLOCAL enabledelayedexpansion
echo sendEmail -t abc#gmail.com -u hellp -f abd#nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstu\a123456 -xp helloworld! -a C:\Users\ll\Desktop\Quotes.docx
echo sendEmail -t abc#gmail.com -u hellp -f abd#nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstu\a123456 -xp helloworld^^! -a C:\Users\ll\Desktop\Quotes.docx
goto:eof
Because your password contains !, batch interprets that as a variable-name if DELAYEDEXPANSION is invoked. Since the variablename isn't set, it's replaced by [nothing] and sendtoemail believes that your password is helloworld\Users\ll\Desktop\Quotes.docx - hence the error message.

Postgres command line install from zip file fails to properly start the windows service after the database has been configured

Below is the batch file I am kicking off at the end of an installer to properly configure my postgres database, however there comes an issue wherein the service is unable to be started.
This is what the service parameters look like:
C:\Program Files\pgsql\bin/pg_ctl.exe runservice -N "MyPostGres" -D "C:/Program Files/pgsql/PGDATA"
Batch file
#echo off
if "%1" == "" goto displayUsage
if "%2" == "" goto displayUsage
if "%3" == "" goto displayUsage
goto setup
:displayUsage
echo supply arguments: SUPER_USER_NAME SUPER_USER_PASSWORD USER_PASSWORD \ >> C:\myLog.log
goto end
:setup
echo %~1 >> C:\myLog.log
echo %~2 >> C:\myLog.log
echo %~3 >> C:\myLog.log
echo calling initdb! >> C:\myLog.log
initdb -U MY_PG ../PGDATA
echo calling pg_ctl register! >> C:\myLog.log
rem provide a variable for PGDATA
pg_ctl register -N TravisPostGres -U MY_PG -P wooo! -D "C:\Program Files\pgsql\PGDATA"
echo calling pg_ctl start! >> C:\myLog.log
pg_ctl start -D ../PGDATA -w
echo calling createuser! %~1 >> C:\myLog.log
createuser -s -UMY_PG %~1
:end
echo the end! >> C:\myLog.log
exit /B 0
I discovered that the issue was the existence of the following file
C:\Program
This file is invisible via explorer view but when executing dir from the c directory it was shown as a 0k file. Deleting this file proved to be the fix.