Change standard separator comma for attachments - windows

I know that comma will be used to separate files and other stuff with Blat mailer.
But I must send files with a comma in their filenames and have no possibility to change this circumstance.
Is there a way to change the standard separator?
Or any other way without changing the filename?
Here my example what I try to do:
set SERVER=127.0.0.1:2525
set USER=sendout#ralfbb-test.local
set PW=secret
set FROMNAME=sendout#ralfbb-test.local
set TO=nurmail1#ralfbb-test.local
set SUBJECT="Subject test - attached file!"
set BODY="Oh yes my dear lad!"
set BODYF="c:\Mailbody.txt"
set ATTACH="c:\517-BS24430-210416-NULL-0,750.pdf"
blat -server %SERVER% -f %FROMNAME% -u %USER% -pw %PW% -to %TO% -subject %SUBJECT% -bodyF %BODYF% -attach %ATTACH% -debug -log blat.log

Add a "" when calling the variable:
"%ATTACH%"

Related

how to load array parameter in another shell file dynamically over ssh connection

I need to call my executable which is placed in an on-prem server by using an ssh connection and pass a dynamics parameter.
based on my requirement, users should be able to add or remove parameters as they want to work with the executable on the on-prem server.
I wrote a translator to identify any new parameter added to the console but now when I want to pass it via ssh, I am facing 2 problems.
what if I have a value that contains space?
how to load these values dynamically & use them as arguments on my shell script on the server?
**Also take note that I am sending some additional parameters that are not related to my executable argument but I need them as well.
params=(
"$MASTER"
"$NAME"
"$QUEUE"
service.enabled=true
)
for var_name in "${!conf__#}";
do
key=${var_name#conf__};
key=${key//_/.};
value=${!var_name};
params+=( --conf "$key=$value" );
done
echo "${params[#]}"
ssh -o StrictHostKeyChecking=no myuser#server_ip "/bin/bash -s" < deploy_script.sh "${params[#]}"
My deploy_script.sh file will be something like the below file.
#!/bin/bash
set -e
AR_MASTER=${1}
AR_NAME=${2}
AR_QUEUE=${3}
AR_SER_EN=${4}
# How can I get the other dynamic parameters???
main() {
my-executable \
"--master "$AR_MASTER \
"--name "$AR_NAME \
"--queue "$AR_QUEUE \
"--conf service.enabled="$AR_SER_EN \
??? #how to add the additional configuration dynamically?
}
main "$#"
Would you mind help me in figure it out?

set CMD output to variable

This is what I have:
> set email=echo abc#xyz.com
> echo %email%
the above snippet echoes echo abc#xyz.com. I want it to print abc#xyz.com instead.
I tried echo abc#xyz.com | set email as well. same result.
How do I do that?
You could let cmd eval it:
#ECHO OFF
set email=echo abc#xyz.com
%email%
I use this on our Windows 10, 2016 and 2019 regulary. I don't know if it works for older versions though.

How do I pipe a file into an encrypted, password protected zip file, then delete the original file, in Windows batch?

I am attempting to export some database data using the BCP Utility.
Here is my batch command so far:
BCP [table] out [file] -c -T -S [server] -t"¶" | 7z.exe a -si [archive name] -sdel
The BCP part works just fine:
BCP [table] out [file] -c -T -S [server] -t"¶"
However, for the 7-Zip part:
7z.exe a -si [archive name] -sdel
It works to a point. The original file is not removed, and I'd also like to encrypt the archive with 128 bit or 256 bit encryption with a password.
Any suggestions?
I found a work around solution with a small VB .NET script.
The script takes in a table name, runs BCP into a text file, runs 7 Zip with encryption options (https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm#Zip), and a password, then deletes the original text file.
These commands are run using the Process() object functions.
That way I can loop through the tables I need placed in files easily.
It is not the Windows batch answer I was looking for, but it works.
Any other suggestions are still welcome.
Thanks!
BCP .... | 7z u -sidirData -pMyPassword -mhe outputFile.7z
^ ^ ^ ^ ^______________ The file that will be generated
| | | |___________________ Encrypt file names
| | |________________________________ Password used for encryption
| |___________________________________________ Name of stored file
|_____________________________________________ update/create container file
Note that there are no spaces between the switches and the values

What does /p mean in set /p?

What does /p stand for in set /p=? I know that / enables a switch, and I'm fairly sure that I know /a is for arithmetic. I've heard numerous rumours, some saying /p is for prompt, others stating it stands for print. The only reason I slightly doubt it is prompt is because in many cases it does not ask for a prompt, yet prints on the screen, such as
<nul set /p=This will not generate a new line
But what I want to know is: Do we really know what it stands for?
The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.
Two ways I've used it... first:
SET /P variable=
When batch file reaches this point (when left blank) it will halt and wait for user input. Input then becomes variable.
And second:
SET /P variable=<%temp%\filename.txt
Will set variable to contents (the first line) of the txt file. This method won't work unless the /P is included. Both tested on Windows 8.1 Pro, but it's the same on 7 and 10.
For future reference, you can get help for any command by using the /? switch, which should explain what switches do what.
According to the set /? screen, the format for set /p is SET /P variable=[promptString] which would indicate that the p in /p is "prompt." It just prints in your example because <nul passes in a nul character which immediately ends the prompt so it just acts like it's printing. It's still technically prompting for input, it's just immediately receiving it.
NOTE: The answers below this point are for a previous version of the question.
/L in for /L generates a List of numbers.
From ping /?:
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP Header).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host-list Loose source route along host-list (IPv4-only).
-k host-list Strict source route along host-list (IPv4-only).
-w timeout Timeout in milliseconds to wait for each reply.
-R Use routing header to test reverse route also (IPv6-only).
-S srcaddr Source address to use.
-4 Force using IPv4.
-6 Force using IPv6.

How can I send an email from the command line using blat when the body contains carriage returns and line feeds?

I have a windows server which sends emails to me through a BASIC program. If the message body contains carriage returns/line feeds then the email never finishes. Only the first line is sent to me. I tried replacing them with \n but that didn't help as the email came to me with the \n in it. Any ideas?
Here is the command I'm using:
blat -to mike.roosa#toltsg.com -subject "[DEV] PO Detail Report" -body "Attached file
is ready for import.
From 01/01/09 to 01/29/09
PO Status not egual to 'C'" -attach "C:\TXT\PODetail_26879.csv" -log
C:\EMAIL.LOG\20090129.TXT -timestamp'.
If you want to do it all inline use the '|' character
-body 1st line|second line|third line
You can put the body in a text file and have blat send that:
blat [text file here] -to mike.roosa#toltsg.com -subject "[DEV] PO Detail Report" -attach "C:\TXT\PODetail_26879.csv" -log
C:\EMAIL.LOG\20090129.TXT -timestamp'
Just use Mail Alert Simple Mailer:
https://sourceforge.net/projects/mail-alert/
MailAlert.exe -r address#example.com -b "#Your_Directory\File_with_Mail_Body.txt"
You can also attach HTML file as an email body (remember to change PlaintextOnly=no in such a case).

Resources